daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Container contentPane = getContentPane();
  2.         contentPane.setLayout(new FlowLayout());
  3.        
  4.         redButton = new JButton("RED");
  5.         redButton.setForeground(Color.RED);
  6.         contentPane.add(redButton);
  7.         redButton.addActionListener(this);
  8.  
  9.     private void changeRedColor()
  10.     {
  11.         Container contentPane = getContentPane();
  12.         contentPane.setBackground(Color.RED);
  13.     }
  14.  
  15. //Vill att dessa två events triggas när den röda knappen klickas, hur gör jag?
  16.  
  17.     public void actionPerformed(ActionEvent event) {
  18.         JButton clickedButton = (JButton) event.getSource();
  19.  
  20.         String  buttonText = clickedButton.getText();
  21.  
  22.         this.setTitle("You clicked " + buttonText);
  23.     }
  24.    
  25.    
  26.     public void actionPerformed(ActionEvent event) {
  27.         changeRedColor();
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top