This commit is contained in:
2023-10-23 13:23:36 +02:00
parent 667dae6f1a
commit 322b22f9bf
5711 changed files with 72953 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FondEvent implements ActionListener{
public JPanel panneau;
public FondEvent(JPanel contenu){
this.panneau = contenu;
}
@Override
public void actionPerformed(ActionEvent evenement){
String couleur = evenement.getActionCommand();
if (couleur=="Cyan"){
panneau.setBackground(Color.CYAN);
}
if (couleur=="Magenta"){
panneau.setBackground(Color.MAGENTA);
}
if (couleur=="Jaune"){
panneau.setBackground(Color.YELLOW);
}
}
}

View File

@@ -0,0 +1,48 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Q4Main{
public static void main(String[] args) {
try{
UIManager.setLookAndFeel("javax.swing.JFrame");
}
catch(ClassNotFoundException e){
System.err.println("ClassNotFoundException");
}
catch(InstantiationException e){
System.err.println("InstantiationException");
}
catch(IllegalAccessException e){
System.err.println("IllegalAccessException");
}
catch(UnsupportedLookAndFeelException e){
System.err.println("UnsupportedLookAndFeelException");
}
catch(ClassCastException e){
System.err.println("ClassCastException");
}
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton boutonCyan = new JButton("Cyan");
JButton boutonMagenta = new JButton("Magenta");
JButton boutonJaune = new JButton("Jaune");
JPanel contenu = new JPanel();
contenu.add(boutonCyan);
contenu.add(boutonMagenta);
contenu.add(boutonJaune);
FondEvent evenementBouton = new FondEvent(contenu);
boutonCyan.addActionListener(evenementBouton);
boutonMagenta.addActionListener(evenementBouton);
boutonJaune.addActionListener(evenementBouton);
fenetre.add(contenu);
fenetre.setVisible(true);
}
}

View File

@@ -0,0 +1,30 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Q4Main{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton boutonCyan = new JButton("Cyan");
JButton boutonMagenta = new JButton("Magenta");
JButton boutonJaune = new JButton("Jaune");
JPanel contenu = new JPanel();
contenu.add(boutonCyan);
contenu.add(boutonMagenta);
contenu.add(boutonJaune);
FondEvent evenementBouton = new FondEvent(contenu);
boutonCyan.addActionListener(evenementBouton);
boutonMagenta.addActionListener(evenementBouton);
boutonJaune.addActionListener(evenementBouton);
fenetre.add(contenu);
fenetre.setVisible(true);
}
}