-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAction.java
More file actions
42 lines (33 loc) · 1.04 KB
/
Action.java
File metadata and controls
42 lines (33 loc) · 1.04 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
package lambda_fn;
import java.awt.event.ActionEvent;
import java.util.EventListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Action {
public static void main(String[] args) {
MyFrame frame = new MyFrame();
}
}
class MyFrame extends JFrame{
JButton button = new JButton("my button");
JButton button1 = new JButton("my button2");
MyFrame(){
button.setBounds(200,200,200,200);
this.add(button);
button.addActionListener(
(e) -> System.out.println("you clicked a button one!")
);
button1.setBounds(300,300,300,300);
button1.addActionListener(
(e) -> System.out.println("you clicked a button second!")
);
this.add(button1);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(420,420);
this.setLayout(null);
this.setVisible(true);
}
}
interface ActionListener extends EventListener{
void acionPerformed(ActionEvent e);
}