TP Exceptions

This commit is contained in:
Simoes Lukas
2025-03-12 17:10:44 +01:00
parent 2a0aa37baa
commit cf33623a5d
45 changed files with 448 additions and 23 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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