-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonDemo.java
More file actions
49 lines (39 loc) · 1.17 KB
/
Copy pathButtonDemo.java
File metadata and controls
49 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package uk.ac.cam.efxlb2.oop.tick5;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class ButtonDemo extends JFrame implements ActionListener {
public ButtonDemo() {
JButton b = new JButton("Click me!");
b.addActionListener(this);
add(b);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Button was clicked!");
}
}
public class ButtonDemo extends JFrame {
public ButtonDemo() {
JButton b = new JButton("Click me!");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Button was clicked!");
}
});
add(b);
}
}
public class ButtonDemo extends JFrame {
public ButtonDemo() {
JButton b = new JButton("Click me!");
b.addActionListener( e -> System.out.println("Button was clicked!"));
add(b);
}
}
//three button demo constructors made - slot them in where the buttons were?
//action needs to be: moveforward, then gamePanel.display() - will gamePanel be available?