Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
//Changement du bord du panel
panelBoutons.setBorder(new TitledBorder("Boutons"));
//Création des 3 boutons
JButton bouton1 = new JButton("bouton 1");
JButton bouton2 = new JButton("bouton 2");
JButton bouton3 = new JButton("bouton 3");
//Changement du layout du panel de boutons et ajout des boutons
panelBoutons.setLayout(new FlowLayout());
panelBoutons.add(bouton1);
panelBoutons.add(bouton2);
panelBoutons.add(bouton3);
//Ajout du label à la fenêtre
mainFrame.add(label);
//Ajout du panel de boutons à la fenêtre
mainFrame.add(panelBoutons);
//’Compactage’ de la fenêtre
mainFrame.pack();
//On quitte l’application quand la fenêtre est fermée
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Affichage de la fenêtre
mainFrame.setVisible(true);}}
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
public class ApplicationSimple {
public static void main(String[] args) {
//Création de la fenêtre de l’application
JFrame mainFrame = new JFrame("EXEMPLE AVEC SWING");
//Changement du layout de la fenêtre
mainFrame.setLayout(new GridLayout(2, 1));
//Création du label contenant le texte
JLabel label = new JLabel(" Bonjour GI2!");
//Création du panel de boutons
JPanel panelBoutons = new JPanel();