Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) ;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement