apl/APL2.1/TP3_Composants_graphiques/Boutons.java
unknown d9949b5cb0 a
2022-01-14 06:54:18 +01:00

34 lines
1.1 KiB
Java

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);
}
}