SyslogFrame.java
2 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.sitech.ismp.ice.syslog;
import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class SyslogFrame extends Frame implements ActionListener {
private SyslogApplet applet;
public SyslogFrame(String title, SyslogApplet app, int x, int y, int w,
int h) {
super(title);
this.applet = app;
this.establishMenuBar();
this.applet.init();
this.add("Center", applet);
this.pack();
this.setLocation(x, y);
this.setSize(w, h);
this.show();
this.applet.start();
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
shutdown();
}
});
}
private void establishMenuBar() {
MenuItem mItem;
MenuBar mbar = new MenuBar();
Menu file = new Menu("File", true);
mbar.add(file);
mItem = new MenuItem("Test Message 1");
mItem.setActionCommand("TEST1");
mItem.addActionListener(this);
file.add(mItem);
mItem = new MenuItem("Test Message 2");
mItem.setActionCommand("TEST2");
mItem.addActionListener(this);
file.add(mItem);
mItem = new MenuItem("Flood 25 Messages ");
mItem.setActionCommand("FLOOD25");
mItem.addActionListener(this);
file.add(mItem);
file.addSeparator();
mItem = new MenuItem("Quit ");
mItem.setActionCommand("QUIT");
mItem.addActionListener(this);
file.add(mItem);
this.setMenuBar(mbar);
}
public void shutdown() {
this.applet.stop();
this.dispose();
System.exit(0);
}
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("QUIT")) {
this.shutdown();
} else if (command.equals("SEND")) {
this.applet.sendMessage();
} else if (command.equals("TEST1")) {
this.applet.runTestOne();
} else if (command.equals("TEST2")) {
this.applet.runTestTwo();
} else if (command.equals("FLOOD25")) {
this.applet.runFloodTest();
}
}
}