1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public static void main(java.lang.String[] args) {
JFrame frame = new JFrame("Test");
frame.getContentPane().setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints(0,0,1,1,1,1,
GridBagConstraints.CENTER,GridBagConstraints.BOTH,
new Insets(0,0,0,0),0,0);
frame.getContentPane().add(new JLabel("label1"),c);
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = GridBagConstraints.REMAINDER;
frame.getContentPane().add(new JLabel("label2"),c);
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 1;
frame.getContentPane().add(new JLabel("label3"),c);
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = GridBagConstraints.REMAINDER;
frame.getContentPane().add(new JLabel("label 4"),c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,200);
frame.setVisible(true);
} |
Partager