TP
This commit is contained in:
45
DEV2.1/TP08/Fond.java
Normal file
45
DEV2.1/TP08/Fond.java
Normal file
@@ -0,0 +1,45 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class Fond {
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(300,200);
|
||||
fenetre.setLocation(100,100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setLayout(new GridLayout(1, 1));
|
||||
|
||||
JPanel panneau = new JPanel();
|
||||
|
||||
JButton bouton1 = new JButton("Cyan");
|
||||
JButton bouton2 = new JButton("Magenta");
|
||||
JButton bouton3 = new JButton("Jaune");
|
||||
|
||||
bouton1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evenement) {
|
||||
panneau.setBackground(Color.CYAN);
|
||||
}
|
||||
});
|
||||
|
||||
bouton2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evenement) {
|
||||
panneau.setBackground(Color.MAGENTA);
|
||||
}
|
||||
});
|
||||
|
||||
bouton3.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evenement) {
|
||||
panneau.setBackground(Color.YELLOW);
|
||||
}
|
||||
});
|
||||
|
||||
panneau.add(bouton1);
|
||||
panneau.add(bouton2);
|
||||
panneau.add(bouton3);
|
||||
|
||||
fenetre.add(panneau);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user