Skip to content

Instantly share code, notes, and snippets.

@anymaniax
Created May 26, 2016 14:51
Show Gist options
  • Save anymaniax/cc52014482297b20e15f367cdb03d3f9 to your computer and use it in GitHub Desktop.
Save anymaniax/cc52014482297b20e15f367cdb03d3f9 to your computer and use it in GitHub Desktop.
public class CouleurAction implements ActionListener{
private JLabel lblCouleur ;
private JPanel pnlPanneau ;
public CouleurAction(JLabel lblCouleur ,JPanel pnlPanneau){
this.lblCouleur=lblCouleur ;
this.pnlPanneau=pnlPanneau ;
}
@Override
public void actionPerformed(ActionEvent e) {
JButton btnSource=(JButton)e.getSource();
lblCouleur.setText( btnSource.getText() ) ;
if(btnSource.getActionCommand( ) == "Rouge" ) {
pnlPanneau.setBackground ( Color.RED) ;
}
else{
pnlPanneau.setBackground ( Color.GREEN) ;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment