-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMessageViewer.java
More file actions
157 lines (148 loc) · 4.7 KB
/
Copy pathMessageViewer.java
File metadata and controls
157 lines (148 loc) · 4.7 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.ScrollPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.text.SimpleDateFormat;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import java.awt.Component;
import java.awt.Cursor;
public class MessageViewer extends JFrame {
@SuppressWarnings("unused")
private static Run thread = null;
private static final long serialVersionUID = 1L;
private ScrollPane contentPane;
static String message;
static boolean intercepted;
//static JTextArea textArea = new JTextArea();
/**
* Launch the application.
*/
public static void main(String[] args) {
SimpleDateFormat time_formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
DefaultTableModel model = (DefaultTableModel) ProKSy.tblLog.getModel();
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MessageViewer frame = new MessageViewer(message,intercepted,thread=null);
frame.setVisible(true);
} catch (Exception e) {
String current_time_str = time_formatter.format(System.currentTimeMillis());
model.addRow(new Object[]{"X", e, current_time_str});
}
}
});
}
public static String newMessage="";
/**
* Create the frame.
* @param message2
*/
public MessageViewer(String message2, boolean intercepted, Run thread) {
JTextArea textArea = new JTextArea();
setTitle("Kingpin Traffic Viewer");
setBounds(100, 100, 380, 240);
JMenuBar menuBar = new JMenuBar();
menuBar.setForeground(Color.LIGHT_GRAY);
menuBar.setOpaque(false);
menuBar.setIgnoreRepaint(true);
menuBar.setAlignmentX(Component.LEFT_ALIGNMENT);
//menuBar.setToolTipText("Forward/Cancel");
setJMenuBar(menuBar);
JMenuItem mnForward = new JMenuItem("Forward");
mnForward.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
mnForward.setAlignmentX(Component.LEFT_ALIGNMENT);
mnForward.setMaximumSize(new Dimension(75, 50));
mnForward.setHorizontalAlignment(SwingConstants.LEFT);
mnForward.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newMessage = textArea.getText();
thread.newMessage = newMessage;
setVisible(false);
thread.res();
}
});
menuBar.add(mnForward);
JMenuItem mnCancel = new JMenuItem("Cancel");
mnCancel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
mnCancel.setAlignmentX(Component.LEFT_ALIGNMENT);
mnCancel.setMaximumSize(new Dimension(75, 50));
mnCancel.setHorizontalAlignment(SwingConstants.LEFT);
mnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newMessage = message2;
thread.newMessage = newMessage;
setVisible(false);
thread.res();
}
});
menuBar.add(mnCancel);
if (!intercepted) {
mnForward.setEnabled(false);
mnCancel.setEnabled(false);
menuBar.setVisible(false);
}
else {
mnForward.setEnabled(true);
mnCancel.setEnabled(true);
}
contentPane = new ScrollPane();
textArea.setLineWrap(true);
textArea.setBackground(ProKSy.mycolor);
textArea.setText(message2.replace("\r\n", ""));
if(!intercepted)
textArea.setEditable(false);
else {
textArea.setEditable(true);
textArea.setBackground(Color.WHITE);
}
contentPane.add(textArea, BorderLayout.NORTH);
setContentPane(contentPane);
this.setPreferredSize(textArea.getPreferredSize());
this.addWindowListener(new WindowListener() {
@Override
public void windowClosing(WindowEvent e) {
if (intercepted) {
thread.newMessage = message2;
setVisible(false);
thread.res();
}
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
});
}
}