35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class Bouton {
|
|
public static void main(String[] args) {
|
|
// un objet pour servir de fenetre
|
|
JFrame fenetre = new JFrame();
|
|
// on configure la fenetre
|
|
fenetre.setSize(500, 300);
|
|
fenetre.setLocation(0, 0);
|
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
// un composant pour afficher du texte
|
|
JButton b1 = new JButton("Bouton 1");
|
|
b1.setHorizontalAlignment(JButton.CENTER);
|
|
fenetre.add(b1, BorderLayout.SOUTH);
|
|
|
|
JButton b2 = new JButton("BoutonBoutonBBoutonBoutonBoutonBoutonBoutonBoutonBoutonouton 2");
|
|
b2.setHorizontalAlignment(JButton.CENTER);
|
|
fenetre.add(b2, BorderLayout.CENTER);
|
|
|
|
JButton b3 = new JButton("Bouton 3");
|
|
b3.setHorizontalAlignment(JButton.CENTER);
|
|
fenetre.add(b3, BorderLayout.NORTH);
|
|
|
|
JButton b4 = new JButton("Bouton 4");
|
|
b4.setHorizontalAlignment(JButton.CENTER);
|
|
fenetre.add(b4, BorderLayout.WEST);
|
|
|
|
JButton b5 = new JButton("Bouton 5");
|
|
b5.setHorizontalAlignment(JButton.CENTER);
|
|
fenetre.add(b5, BorderLayout.EAST);
|
|
// et on montre le resultat
|
|
fenetre.setVisible(true);
|
|
}
|
|
} |