import javax.swing.*; import java.awt.*; public class Boutons{ public static void main(String[] args) { JFrame fenetre = new JFrame(); //Objet representant la fenetre fenetre.setSize(500, 300); //taille de la fenetre fenetre.setLocation(0, 0); //position de la fenetre dans l'ecran fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bouton1 = new JButton("bouton 1"); JButton bouton2 = new JButton("bouton 2"); JButton bouton3 = new JButton("bouton 3"); JButton bouton4 = new JButton("bouton 4"); JButton bouton5 = new JButton("bouton 5"); bouton1.setHorizontalAlignment(JButton.CENTER); fenetre.add(bouton1, BorderLayout.CENTER); bouton2.setHorizontalAlignment(JButton.CENTER); fenetre.add(bouton2, BorderLayout.SOUTH); bouton3.setHorizontalAlignment(JButton.CENTER); fenetre.add(bouton3, BorderLayout.NORTH); bouton4.setHorizontalAlignment(JButton.CENTER); fenetre.add(bouton4, BorderLayout.WEST); bouton5.setHorizontalAlignment(JButton.CENTER); fenetre.add(bouton5, BorderLayout.EAST); fenetre.setVisible(true); } }