ajout vieux sujet
This commit is contained in:
33
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETA/EXO3/Menu.java
Normal file
33
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETA/EXO3/Menu.java
Normal file
@@ -0,0 +1,33 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Menu {
|
||||
private JButton[] boutons;
|
||||
|
||||
public Menu(String args[]) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500,500);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
this.boutons = new JButton[args.length];
|
||||
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.setLayout(new GridLayout(args.length, 1));
|
||||
|
||||
int i = 0;
|
||||
for (String element : args) {
|
||||
this.boutons[i] = new JButton(element);
|
||||
panneau.add(this.boutons[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
fenetre.add(panneau);
|
||||
|
||||
// Utiliser pack() pour ajuster la taille de la fenêtre en fonction des composants
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Menu test = new Menu(args);
|
||||
}
|
||||
}
|
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETA/EXO3/MenuApp.class
Normal file
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETA/EXO3/MenuApp.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user