Recherche personnalisée

Exemple : BoxLayout



JBuilder - Ex1_11.java

Ex1_11.java
/*BoxLayout*/
import java.awt.*;
import javax.swing.*;

public class Ex1_11  {

  // Déclaration des composants

    JFrame frame;
    JButton b1,b2,b3,b4,b5;


// Création et affichage de la fenêtre
    public Ex1_11() {

        frame = new JFrame("BOXLAYOUT");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        b1=new JButton("Haut");
        b2=new JButton("Bas");
        b3=new JButton("Gauche");
        b4=new JButton("Droite");
        b5=new JButton("Centre");

 //frame.setLayout(new BoxLayout(frame, BoxLayout.Y_AXIS));

 frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
                b1.setAlignmentX(b1.CENTER_ALIGNMENT);
                b2.setAlignmentX(b1.CENTER_ALIGNMENT);
                b3.setAlignmentX(b1.CENTER_ALIGNMENT);
                b4.setAlignmentX(b1.CENTER_ALIGNMENT);
                b5.setAlignmentX(b1.CENTER_ALIGNMENT);
        frame.add(b1);
        frame.add(b2);
        frame.add(b3);
        frame.add(b4);
        frame.add(b5);

        frame.pack();
        frame.setVisible(true);

    }


    private static void afficher() {

        Ex1_11 f = new Ex1_11();

    }

    public static void main(String[] args) {  javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                afficher();
            }
        });
    }




}



Ex1_11.java

calle
calle
calle

Suivre la vie de ce site RSS -
HitMaroc.net
Formation GoogleCe site est listé dans la catégorie Informatique : Programmation informatique Dictionnaire