import java.util.*; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import javax.swing.event.*; class BoxLayoutFrame extends JFrame { public BoxLayoutFrame() { setTitle ("Fichier"); setSize(DEFAULT_WIDHT,DEFAULT_HEIGHT); Container contentPane = getContentPane(); //FlowLayout layout = new FlowLayout(); // Container.setLayout( layout ); JLabel label1 = new JLabel("Serveur"); JTextField textField1 = new JTextField(30); textField1.setMaximumSize(textField1.getPreferredSize()); Box hbox1 = Box.createHorizontalBox (); hbox1.add(label1); hbox1.add(Box.createHorizontalStrut(30)); hbox1.add(textField1); JLabel label2 = new JLabel("Port "); JTextField textField2 = new JTextField(30); textField2.setMaximumSize(textField2.getPreferredSize()); Box hbox2 = Box.createHorizontalBox (); hbox2.add(label2); hbox2.add(Box.createHorizontalStrut(30)); hbox2.add(textField2); // creer les zones de texte //JTextField textField3 = new JTextField(30); //textField3.setText(" Client"); //texField3.addActionListener(this); JLabel label3 = new JLabel("Client"); JTextArea textArea1 = new JTextArea (5, 5); JScrollPane scrollPane1 = new JScrollPane(textArea1,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); textArea1.setEditable(false); Box hbox3 = Box.createHorizontalBox (); Box hbox4 = Box.createHorizontalBox (); hbox3.add(label3); hbox3.add(Box.createHorizontalStrut(200)); hbox4.add(scrollPane1); hbox4.add(textArea1); JLabel label4 = new JLabel("serveur"); JTextArea textArea2 = new JTextArea (5, 5); JScrollPane scrollPane2 = new JScrollPane(textArea2,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); textArea2.setEditable(false); //Box hbox4 = Box.createVerticalBox (5); hbox3.add(label4); // hbox4.add(Box.createVerticalStrut(20)); hbox4.add(scrollPane2); hbox4.add(textArea2); hbox4.add(Box.createGlue()); // creer le menu fichier JMenuBar barreMenus; JMenu fichier; barreMenus = new JMenuBar(); setJMenuBar(barreMenus); fichier = new JMenu("Fichier"); barreMenus.add(fichier); JButton button1 = new JButton("Connexion"); JButton button2 = new JButton("Termine"); Box hbox5 = Box.createHorizontalBox (); hbox5.add(button1); hbox5.add(Box.createGlue()); hbox5.add(button2); //hbox5.add(Box.createHorizontalGlue(60)); Box vbox = Box.createVerticalBox(); vbox.add(hbox1); vbox.add(hbox2); vbox.add(Box.createGlue()); vbox.add(hbox3); //contentPane.add(textArea1,BorderLayout.WEST); vbox.add(hbox4); vbox.add(hbox5); this.add(vbox); } public static final int DEFAULT_WIDHT = 500; public static final int DEFAULT_HEIGHT = 500; } public class TestBoxLayoutFrame { // une classe pour tester public static void main (String args[] ) { BoxLayoutFrame blf1 = new BoxLayoutFrame (); // construction blf1.setVisible (true ) ; // rend la fenetre "active" blf1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // choix du comportement a la fermeture de la fenetre } } // c'est tout ,swing fait le reste !!!