source: tmcsimulator/trunk/src/tmcsim/client/CADClockView.java @ 61

Revision 61, 2.2 KB checked in by jdalbey, 9 years ago (diff)

CADClock development.

Line 
1package tmcsim.client;
2
3import java.awt.Color;
4import java.awt.Dimension;
5import java.awt.Font;
6import java.awt.event.KeyEvent;
7import java.awt.event.KeyListener;
8import java.util.Observable;
9import java.util.Observer;
10import java.util.logging.Logger;
11
12import javax.swing.BorderFactory;
13import javax.swing.Box;
14import javax.swing.BoxLayout;
15import javax.swing.JFrame;
16import javax.swing.JLabel;
17import javax.swing.JOptionPane;
18import javax.swing.JPanel;
19import javax.swing.WindowConstants;
20import tmcsim.common.ObserverMessage;
21import tmcsim.common.CADEnums.CADScreenNum;
22import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus;
23
24/**
25 * The CADClientView class is the view component to the CAD Client application.
26 *
27 * This view class observers the CADClientModel, listening for updates from the
28 * CAD Simulator. Updates includes the current CAD time
29 */
30@SuppressWarnings("serial")
31public class CADClockView extends JFrame
32{
33
34    /**
35     * Error Logger.
36     */
37    private static Logger cadLogger = Logger.getLogger("tmcsim.client");
38    private JPanel mainPane;
39    private JLabel currentTime;
40
41    /**
42     * Constructor. Build panes, add key listeners, and set up observer
43     * relationship between the footer and main panes.
44     *
45     * @param position The CAD position for this client terminal.
46     */
47    public CADClockView()
48    {
49        super("CAD Client");
50        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
51        currentTime = new JLabel("0:00:00");
52        CADSimulatorStatus status = new CADSimulatorStatus();
53        String simtime = status.getCurrentTime();
54        currentTime.setText(simtime);
55        currentTime.setAlignmentX(Box.CENTER_ALIGNMENT);
56        currentTime.setFont(new Font("Geneva", Font.BOLD, 70));
57        mainPane = new JPanel();
58        setSize(new Dimension(730, 455));
59        setMaximumSize(new Dimension(730, 455));
60        setMinimumSize(new Dimension(730, 455));
61        mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
62        mainPane.setBorder(BorderFactory.createLineBorder(Color.black));
63        mainPane.setBackground(Color.LIGHT_GRAY);
64        mainPane.add(currentTime);
65        add(mainPane);
66        pack();
67    }
68
69    public void updateTime(String msg)
70    {
71        currentTime.setText(msg);
72    }
73}
Note: See TracBrowser for help on using the repository browser.