public static final int PORT = 192;
public static void main(String[] args) {
//new client
final LoggerModel lms = new LoggerModel();
//new connection to client
GRTClientSocket gcs = new GRTClientSocket(IP, PORT);
gcs.start();
gcs.addSocketListener(lms);
//new panel
LoggerUI lu = new LoggerUI(lms);
JFrame vars = new JFrame("vars");
vars.setLayout(new BorderLayout());
VariableUI v = new VariableUI(lms);
vars.add(v,BorderLayout.CENTER);
vars.setSize(500, 500);
vars.setVisible(true);
//new frame
final JFrame j = new JFrame("Logger UI");
//menu bar and co.
JMenuBar bar = new JMenuBar();
JMenu file = new JMenu("File");
JMenu log = new JMenu("Log");
//add item to log
JMenuItem write = new JMenuItem("Write to file");
log.add(write);
JMenuItem getVers = new JMenuItem("Print version");
log.add(getVers);
//ad menu bar to frame
j.setJMenuBar(bar);
bar.add(file);
bar.add(log);
write.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
lms.writeLogs();
}
});
getVers.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int i = lms.getLastVersion();
JOptionPane.showMessageDialog(j, i);
}
});
j.setSize(500, 500);
j.add(lu, BorderLayout.CENTER);
j.setVisible(true);
j.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
j.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
lms.writeLogs();
System.exit(0);
}
});
}