I am new in java applications and I am trying to create a window with 3 buttons in a row at the bottom of the window with extended size. However gridheight doesn't have any affect on my buttons. gridwidth works fine.
Can you give me a feedback on what I am doing wrong? I guess I haven't understand something correctly.
Bellow is my code and the output window.
Thanx in advance!
private JButton button1;
private JButton button2;
private JButton button3;
public SessionTasksPage()
{
JPanel p1=new JPanel(new GridBagLayout());
JPanel p2=new JPanel();
button1 = new JButton("b1");
button2 = new JButton("b2");
button3 = new JButton("b3");
GridBagConstraints gbc =new GridBagConstraints();
//gbc.insets = new Insets(1,1,1,1);
gbc.gridheight = 5;
gbc.gridwidth = 5;
gbc.weightx=15;
gbc.weighty=15;
gbc.fill = GridBagConstraints.BOTH;
p1.add(button2,gbc);
p1.add(button3,gbc);
p1.add(button1,gbc);
add(p1,BorderLayout.SOUTH);
add(p2,BorderLayout.NORTH);
EventHandler1 event1 = new EventHandler1();
button1.addActionListener(event1);
//window terminate setting
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//window size
setSize(600,400);
//pack();
//make window visible
setVisible(true);
//window title
setTitle("HCI-Projet");
//voice command
//new AePlayerWave("bin/sounds/login.wav").start();
}
public class EventHandler1 implements ActionListener
{
public void actionPerformed(ActionEvent event1) {
System.exit(0);
}
}