Advertisement
Guest User

Untitled

a guest
May 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public class CouleurAction implements ActionListener{
  2. private JLabel lblCouleur ;
  3. private JPanel pnlPanneau ;
  4. public CouleurAction(JLabel lblCouleur ,JPanel pnlPanneau){
  5. this.lblCouleur=lblCouleur ;
  6. this.pnlPanneau=pnlPanneau ;
  7. }
  8. @Override
  9. public void actionPerformed(ActionEvent e) {
  10. JButton btnSource=(JButton)e.getSource();
  11. lblCouleur.setText( btnSource.getText() ) ;
  12. if(btnSource.getActionCommand( ) == "Rouge" ) {
  13. pnlPanneau.setBackground ( Color.RED) ;
  14. }
  15. else{
  16. pnlPanneau.setBackground ( Color.GREEN) ;
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement