2023-04-18 12:29:43 +02:00
|
|
|
import java.awt.event.*;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class ModificationsFVG implements MouseListener {
|
|
|
|
private int[] ce_tableau ;
|
|
|
|
private OptionsFVG options;
|
|
|
|
|
|
|
|
public ModificationsFVG(OptionsFVG options, int[] un_tab){
|
|
|
|
this.options = options;
|
|
|
|
this.ce_tableau = un_tab;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
JPanel notre_Panel = (JPanel) e.getSource();
|
|
|
|
|
|
|
|
Color test = notre_Panel.getBackground();
|
|
|
|
|
|
|
|
// Accéder aux boutons radios de l'objet Options
|
|
|
|
boolean radio1Selected = options.GetButtonBW().isSelected();
|
|
|
|
boolean radio2Selected = options.GetButtonE().isSelected();
|
|
|
|
boolean radio3Selected = options.GetButtonS().isSelected();
|
|
|
|
|
|
|
|
if(test==Color.WHITE && radio1Selected==true){
|
|
|
|
notre_Panel.setBackground(Color.BLACK);
|
|
|
|
} else if(test==Color.BLACK && radio1Selected==true){
|
|
|
|
notre_Panel.setBackground(Color.WHITE);
|
|
|
|
}else if(radio1Selected==true && (test==Color.RED || test==Color.BLUE)){
|
|
|
|
if(test==Color.BLUE){
|
|
|
|
notre_Panel.setBackground(Color.WHITE);
|
|
|
|
this.ce_tableau[0] = 0;
|
|
|
|
} else if(test==Color.RED){
|
|
|
|
notre_Panel.setBackground(Color.WHITE);
|
|
|
|
this.ce_tableau[1] = 0;
|
|
|
|
}
|
|
|
|
} else if(test!=Color.BLUE && radio2Selected==true && this.ce_tableau[0]==0){
|
|
|
|
notre_Panel.setBackground(Color.BLUE);
|
|
|
|
this.ce_tableau[0]=1;
|
|
|
|
} else if(test!=Color.RED && radio3Selected==true && this.ce_tableau[1]==0){
|
|
|
|
this.ce_tableau[1]=1;
|
|
|
|
notre_Panel.setBackground(Color.RED);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-19 19:13:00 +02:00
|
|
|
public int[] getValues(){
|
2023-04-18 12:29:43 +02:00
|
|
|
return this.ce_tableau;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) {
|
|
|
|
// Laisser cette méthode vide si vous n'avez pas besoin de l'utiliser
|
|
|
|
}
|
|
|
|
|
|
|
|
// Les méthodes suivantes ne sont pas utilisées dans cet exemple, donc nous les laissons vides
|
|
|
|
public void mouseReleased(MouseEvent e) {}
|
|
|
|
public void mousePressed(MouseEvent e) {}
|
|
|
|
public void mouseEntered(MouseEvent e) {}
|
|
|
|
}
|