updated code for kona libs, not quite working yet.
[feisty_meow.git] / kona / src / org / feistymeow / windowing / WindowUtilities.java
1 package org.feistymeow.windowing;\r
2 \r
3 import javax.swing.*;\r
4 import java.awt.*;\r
5 \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
8  */\r
9 \r
10 public class WindowUtilities {\r
11 \r
12   /** Tell system to use native look and feel, as in previous\r
13    *  releases. Metal (Java) LAF is the default otherwise.\r
14    */\r
15 \r
16   public static void setNativeLookAndFeel() {\r
17     try {\r
18       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
19     } catch(Exception e) {\r
20       System.out.println("Error setting native LAF: " + e);\r
21     }\r
22   }\r
23 \r
24   public static void setJavaLookAndFeel() {\r
25     try {\r
26       UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
27     } catch(Exception e) {\r
28       System.out.println("Error setting Java LAF: " + e);\r
29     }\r
30   }\r
31 \r
32    public static void setMotifLookAndFeel() {\r
33     try {\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
37     }\r
38   }\r
39 \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
42    */\r
43 \r
44   public static JFrame openInJFrame(Container content,\r
45                                     int width,\r
46                                     int height,\r
47                                     String title,\r
48                                     Color bgColor) {\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
56     return(frame);\r
57   }\r
58 \r
59   /** Uses Color.white as the background color. */\r
60 \r
61   public static JFrame openInJFrame(Container content,\r
62                                     int width,\r
63                                     int height,\r
64                                     String title) {\r
65     return(openInJFrame(content, width, height, title, Color.white));\r
66   }\r
67 \r
68   /** Uses Color.white as the background color, and the\r
69    *  name of the Container's class as the JFrame title.\r
70    */\r
71 \r
72   public static JFrame openInJFrame(Container content,\r
73                                     int width,\r
74                                     int height) {\r
75     return(openInJFrame(content, width, height,\r
76                         content.getClass().getName(),\r
77                         Color.white));\r
78   }\r
79 }\r