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
|
// TODO Auto-generated method stub
JFrame panel = new JFrame();
panel.setSize(800, 600);
panel.setLayout(new GridBagLayout());
JPanel jp1 = new JPanel();
jp1.setBackground(Color.blue);
JPanel jp2 = new JPanel();
jp2.setBackground(Color.red);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.8;
c.weighty = 1;
panel.add(jp1,c);
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 1;
c.gridy = 0;
c.weightx = 0.2;
c.weighty = 1;
panel.add(jp2,c);
panel.setLocationRelativeTo(null);
panel.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
panel.setVisible(true); |
Partager