• # Swing

    Posté par . En réponse au message Gridbaglayout et GTK. Évalué à 1.

    Salut,

    pour Swing il faut en général combiner les propriétés de plusieurs Layout : BorderLayout pour l'emplacement "en gros" des composants, et GridBagLayout pour les formulaire , FlowLayout eventuellement pour les barres de boutons.

    Pour répondre a ta question, tes trois panels du haut sont un JPanel avec un BorderLayout, panel lui meme inclu en BorderLayout.CENTER. La barre de bouton du bas est un FlowLayout orienté à l'est inclu en BorderLayout.SOUTH

    Le code ressemble a peu pres à ca :

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jPanel2 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();

    setLayout(new java.awt.BorderLayout());

    jPanel1.setLayout(new java.awt.BorderLayout());

    jLabel1.setText("jLabel1");
    jPanel1.add(jLabel1, java.awt.BorderLayout.WEST);

    jLabel2.setText("jLabel2");
    jPanel1.add(jLabel2, java.awt.BorderLayout.CENTER);

    jLabel3.setText("jLabel3");
    jPanel1.add(jLabel3, java.awt.BorderLayout.EAST);

    jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

    jButton1.setText("jButton1");
    jPanel2.add(jButton1);

    jButton2.setText("jButton2");

    jPanel2.add(jButton2);

    jPanel1.add(jPanel2, java.awt.BorderLayout.SOUTH);

    add(jPanel1, java.awt.BorderLayout.CENTER);