TP Exceptions
This commit is contained in:
BIN
DEV2.1/TP10/04_Apparences/Fond$1.class
Normal file
BIN
DEV2.1/TP10/04_Apparences/Fond$1.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP10/04_Apparences/Fond$2.class
Normal file
BIN
DEV2.1/TP10/04_Apparences/Fond$2.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP10/04_Apparences/Fond$3.class
Normal file
BIN
DEV2.1/TP10/04_Apparences/Fond$3.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP10/04_Apparences/Fond.class
Normal file
BIN
DEV2.1/TP10/04_Apparences/Fond.class
Normal file
Binary file not shown.
58
DEV2.1/TP10/04_Apparences/Fond.java
Normal file
58
DEV2.1/TP10/04_Apparences/Fond.java
Normal file
@@ -0,0 +1,58 @@
|
||||
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) {
|
||||
try {
|
||||
try {
|
||||
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
} catch (InstantiationException e2) {
|
||||
} catch (IllegalAccessException e3) {
|
||||
} catch (UnsupportedLookAndFeelException e4) {
|
||||
} // On constate que les boutons changent d'apparence
|
||||
catch (ClassCastException e5) {
|
||||
System.out.println("Nom de manager incorrect");
|
||||
} // Les boutons restent comme avant
|
||||
|
||||
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