1 package org.feistymeow.windowing;
\r
3 import javax.swing.*;
\r
6 /** A few utilities that simplify using windows in Swing.
\r
7 * 1998-99 Marty Hall, http://www.apl.jhu.edu/~hall/java/
\r
10 public class WindowUtilities {
\r
12 /** Tell system to use native look and feel, as in previous
\r
13 * releases. Metal (Java) LAF is the default otherwise.
\r
16 public static void setNativeLookAndFeel() {
\r
18 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
\r
19 } catch(Exception e) {
\r
20 System.out.println("Error setting native LAF: " + e);
\r
24 public static void setJavaLookAndFeel() {
\r
26 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
\r
27 } catch(Exception e) {
\r
28 System.out.println("Error setting Java LAF: " + e);
\r
32 public static void setMotifLookAndFeel() {
\r
34 UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
\r
35 } catch(Exception e) {
\r
36 System.out.println("Error setting Motif LAF: " + e);
\r
40 /** A simplified way to see a JPanel or other Container.
\r
41 * Pops up a JFrame with specified Container as the content pane.
\r
44 public static JFrame openInJFrame(Container content,
\r
49 JFrame frame = new JFrame(title);
\r
50 frame.setBackground(bgColor);
\r
51 content.setBackground(bgColor);
\r
52 frame.setSize(width, height);
\r
53 frame.setContentPane(content);
\r
54 frame.addWindowListener(new ExitListener());
\r
55 frame.setVisible(true);
\r
59 /** Uses Color.white as the background color. */
\r
61 public static JFrame openInJFrame(Container content,
\r
65 return(openInJFrame(content, width, height, title, Color.white));
\r
68 /** Uses Color.white as the background color, and the
\r
69 * name of the Container's class as the JFrame title.
\r
72 public static JFrame openInJFrame(Container content,
\r
75 return(openInJFrame(content, width, height,
\r
76 content.getClass().getName(),
\r