package tmcsim.client; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Observable; import java.util.Observer; import java.util.logging.Logger; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.WindowConstants; import tmcsim.common.ObserverMessage; import tmcsim.common.CADEnums.CADScreenNum; import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; /** * The CADClientView class is the view component to the CAD Client application. * * This view class observers the CADClientModel, listening for updates from the * CAD Simulator. Updates includes the current CAD time */ @SuppressWarnings("serial") public class CADClockView extends JFrame { /** * Error Logger. */ private static Logger cadLogger = Logger.getLogger("tmcsim.client"); private JPanel mainPane; private JLabel currentTime; /** * Constructor. Build panes, add key listeners, and set up observer * relationship between the footer and main panes. * * @param position The CAD position for this client terminal. */ public CADClockView() { super("CAD Client"); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); currentTime = new JLabel("0:00:00"); CADSimulatorStatus status = new CADSimulatorStatus(); String simtime = status.getCurrentTime(); currentTime.setText(simtime); currentTime.setAlignmentX(Box.CENTER_ALIGNMENT); currentTime.setFont(new Font("Geneva", Font.BOLD, 70)); mainPane = new JPanel(); setSize(new Dimension(730, 455)); setMaximumSize(new Dimension(730, 455)); setMinimumSize(new Dimension(730, 455)); mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); mainPane.setBackground(Color.LIGHT_GRAY); mainPane.add(currentTime); add(mainPane); pack(); } public void updateTime(String msg) { currentTime.setText(msg); } }