-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEnterPoint.java
executable file
·45 lines (39 loc) · 1.06 KB
/
EnterPoint.java
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
import javax.swing.*;
import java.awt.event.*;
public class EnterPoint extends JFrame {
public static void main(String[] args){
new EnterPoint();
}
private Daemon daemon;
public EnterPoint(){
super("Daemon thread try stopping");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(150,100);
this.init();
this.setVisible(true);
}
public void init(){
JPanel panel_main=new JPanel();
JButton button_start=new JButton("start");
button_start.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
on_button_start_click();
}
});
JButton button_stop=new JButton("stop");
button_stop.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
on_button_stop_click();
}
});
panel_main.add(button_start);
panel_main.add(button_stop);
this.getContentPane().add(panel_main);
}
private void on_button_start_click(){
daemon=new Daemon("Simple Daemon ",1000);
}
private void on_button_stop_click(){
daemon.stop();
}
}