| 1 | package tmcsim.client; |
|---|
| 2 | |
|---|
| 3 | import java.awt.Color; |
|---|
| 4 | import java.awt.Dimension; |
|---|
| 5 | import java.awt.Font; |
|---|
| 6 | import java.util.logging.Logger; |
|---|
| 7 | import javax.swing.BorderFactory; |
|---|
| 8 | import javax.swing.Box; |
|---|
| 9 | import javax.swing.BoxLayout; |
|---|
| 10 | import javax.swing.JFrame; |
|---|
| 11 | import javax.swing.JLabel; |
|---|
| 12 | import javax.swing.JPanel; |
|---|
| 13 | import javax.swing.WindowConstants; |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * The CADClientView class is the view component to the CAD Client application. |
|---|
| 17 | * |
|---|
| 18 | * @author jdalbey |
|---|
| 19 | */ |
|---|
| 20 | @SuppressWarnings("serial") |
|---|
| 21 | public class ClockView extends JFrame |
|---|
| 22 | { |
|---|
| 23 | /** |
|---|
| 24 | * Error Logger. |
|---|
| 25 | */ |
|---|
| 26 | private static Logger cadLogger = Logger.getLogger("tmcsim.client"); |
|---|
| 27 | private JPanel mainPane; |
|---|
| 28 | private JLabel currentTime; |
|---|
| 29 | private final static Dimension SCREEN_SIZE = new Dimension(1100, 255); |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * Constructor. Build panes, add key listeners, and set up observer |
|---|
| 33 | * relationship between the footer and main panes. TODO: Consider having |
|---|
| 34 | * screen size and font size in properties file. |
|---|
| 35 | */ |
|---|
| 36 | public ClockView() |
|---|
| 37 | { |
|---|
| 38 | super("Simulation Clock"); |
|---|
| 39 | this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|---|
| 40 | currentTime = new JLabel("00:00:00"); |
|---|
| 41 | currentTime.setAlignmentX(Box.CENTER_ALIGNMENT); |
|---|
| 42 | currentTime.setFont(new Font("Geneva", Font.BOLD, 200)); |
|---|
| 43 | mainPane = new JPanel(); |
|---|
| 44 | setSize(SCREEN_SIZE); |
|---|
| 45 | setMaximumSize(SCREEN_SIZE); |
|---|
| 46 | setMinimumSize(SCREEN_SIZE); |
|---|
| 47 | mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
|---|
| 48 | mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); |
|---|
| 49 | mainPane.setBackground(new Color(230, 230, 230)); // #E6E6E6 |
|---|
| 50 | mainPane.add(currentTime); |
|---|
| 51 | add(mainPane); |
|---|
| 52 | pack(); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | public void updateTime(String msg) |
|---|
| 56 | { |
|---|
| 57 | currentTime.setText(msg); |
|---|
| 58 | } |
|---|
| 59 | } |
|---|