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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
public class Test extends JFrame {
public static void main(String[] args) {
Test fenetre = new Test();
fenetre.getContentPane().setLayout(new GridBagLayout());
GridBagConstraints c1 = new GridBagConstraints();
c1.gridx = 0;
c1.gridy = 0;
c1.gridwidth = 7;
c1.gridheight = 1;
c1.fill = GridBagConstraints.BOTH;
c1.anchor = GridBagConstraints.EAST;
c1.weightx = 0;
c1.weighty = 0;
fenetre.getContentPane().add(new JTextField(10), c1);
GridBagConstraints c2 = new GridBagConstraints();
c2.gridx = 7;
c2.gridy = 0;
c2.gridwidth = 19;
c2.gridheight = 1;
c2.fill = GridBagConstraints.BOTH;
c2.weightx = 0;
c2.weighty = 0;
fenetre.getContentPane().add(new JTextField(40), c2);
GridBagConstraints c3 = new GridBagConstraints();
c3.gridx = 0;
c3.gridy = 1;
c3.gridwidth = 5;
c3.gridheight = 1;
c3.fill = GridBagConstraints.BOTH;
c3.anchor = GridBagConstraints.EAST;
c3.weightx = 0;
c3.weighty = 0;
fenetre.getContentPane().add(new JLabel("Preseries"), c3);
GridBagConstraints c4 = new GridBagConstraints();
c4.gridx = 5;
c4.gridy = 1;
c4.gridwidth = 8;
c4.gridheight = 1;
c4.fill = GridBagConstraints.BOTH;
c4.weightx = 0;
c4.weighty = 0;
fenetre.getContentPane().add(new JTextField(25), c4);
fenetre.setSize(600, 300);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setVisible(true);
}
} |
Partager