Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Container contentPane = getContentPane();
- contentPane.setLayout(new FlowLayout());
- redButton = new JButton("RED");
- redButton.setForeground(Color.RED);
- contentPane.add(redButton);
- redButton.addActionListener(this);
- private void changeRedColor()
- {
- Container contentPane = getContentPane();
- contentPane.setBackground(Color.RED);
- }
- //Vill att dessa två events triggas när den röda knappen klickas, hur gör jag?
- public void actionPerformed(ActionEvent event) {
- JButton clickedButton = (JButton) event.getSource();
- String buttonText = clickedButton.getText();
- this.setTitle("You clicked " + buttonText);
- }
- public void actionPerformed(ActionEvent event) {
- changeRedColor();
- }
Add Comment
Please, Sign In to add comment