package com.rle.monitor; /* * RLE Surface Crack Detector Graphing Software * * Copyright (C) 2002 RLE Technologies * For more information visit http://www.rletech.com/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /** * @author Andy Goth * @author Eric Peterson * @author Matt Lane * @version 0.1 */ import java.awt.*; import java.awt.event.*; import java.lang.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; /** The main window. */ public class Window extends JFrame { private App app; private JPanel panel; /** Constructor. */ public Window(App app) { super("RLE Monitor"); this.app = app; getRootPane().setBorder(new LineBorder( UIManager.getColor("control"), 3)); Font font = new Font(null, Font.PLAIN, 10); UIManager.put("Button.font", font); UIManager.put("CheckBox.font", font); UIManager.put("Label.font", font); UIManager.put("Label.foreground", Color.black); UIManager.put("Menu.font", font); UIManager.put("MenuItem.font", font); UIManager.put("RadioButtonMenuItem.font", font); UIManager.put("Spinner.font", font); UIManager.put("Spinner.focus", UIManager.get("Button.focus")); setSize(240, 320); setResizable(true); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (panel != null) panel.revalidate(); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { shutdown(); } }); } /** Stops the program. */ private void shutdown() {app.shutdown();} /** Returns the currently displayed panel. */ public JPanel getPanel() {return panel;} /** Changes the currently displayed panel. */ public void setPanel(JPanel panel) { if (panel != app.getDisplay() && panel != app.getSetup()) throw new IllegalArgumentException("Invalid panel"); if (this.panel == panel) return; setContentPane(panel); if (this.panel == null) show(); this.panel = panel; } }