JFrame f = new JFrame("DF"); f.setSize(400, 200); f.setLocation(300,300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane=f.getContentPane();
pane.setLayout(new GridBagLayout());
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridx=1;
gbc.gridy=GridBagConstraints.RELATIVE;
pane.add(new JButton("AAA"), gbc);
pane.add(new JButton("b"), gbc); // "B" must be below the A
gbc.gridwidth=2;
pane.add(new JButton("c"), gbc); // now C must be next to the "A"
gbc.gridwidth=1;
gbc.gridx=GridBagConstraints.RELATIVE;
pane.add(new JButton("DDD"), gbc);
I don't understand
1) what does the gbc.gridwidth=2 and gbc.gridwidth=1 means?
2) why is "DDD" next to the A?
3) why is C Centered horizontally?
4) how to set border color to the table colums and rows here?...
please explane me what does gridwith and gridheight makes.


Sign In
Create Account


Back to top









