COMP2396
Loading...
Searching...
No Matches
SimpleGUI3.java
Go to the documentation of this file.
1import javax.swing.*;
2import java.awt.*;
3import java.awt.event.*;
4
5public class SimpleGUI3 implements ActionListener {
6 JFrame frame;
7
8 public static void main(String[] args) {
9 SimpleGUI3 gui = new SimpleGUI3();
10 gui.go();
11 }
12
13 public void go() {
14 frame = new JFrame();
15 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16 JButton button = new JButton("Change colors");
17 button.addActionListener(this);
18 MyDrawPanel2 drawPanel = new MyDrawPanel2();
19 frame.add(button, BorderLayout.SOUTH);
20 frame.add(drawPanel, BorderLayout.CENTER);
21 frame.setSize(300, 300);
22 frame.setVisible(true);
23 }
24
25 public void actionPerformed(ActionEvent event) {
26 frame.repaint();
27 }
28}
static void main(String[] args)
void actionPerformed(ActionEvent event)