Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/arranger/jarl/shell/views/ViewUtil.java


1   package com.arranger.jarl.shell.views;
2   
3   import javax.swing.*;
4   import java.awt.*;
5   
6   /**
7    * ViewUtil created on Apr 16, 2003
8    */
9   public class ViewUtil {
10  
11      /**
12       * Tell system to use native look and feel, as in previous
13       *  releases. Metal (Java) LAF is the default otherwise.
14       */
15      public static void initNativeLookAndFeel() {
16          try {
17              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
18          } catch (Exception e) {
19              System.out.println("Error setting native LAF: " + e);
20          }
21          JFrame.setDefaultLookAndFeelDecorated(true);
22      }
23  
24      /**
25       * A simplified way to see a JPanel or other Container.
26       *  Pops up a JFrame with specified Container as the content pane.
27       */
28      public static JFrame openInJFrame(Container content,
29                                        int width,
30                                        int height,
31                                        String title,
32                                        Color bgColor) {
33          JFrame frame = new JFrame(title);
34          frame.setBackground(bgColor);
35          content.setBackground(bgColor);
36          frame.setSize(width, height);
37          frame.setContentPane(content);
38          return frame;
39      }
40  
41      /**
42       * You might want to do some stuff prior to opening it
43       * @param jframe
44       */
45      public static void packAndShow(JFrame jframe) {
46          jframe.pack();
47          jframe.setVisible(true);
48          jframe.show();
49      }
50  
51      /** Uses Color.white as the background color. */
52  
53      public static JFrame openInJFrame(Container content,
54                                        int width,
55                                        int height,
56                                        String title) {
57          return openInJFrame(content, width, height, title, SystemColor.window);
58      }
59  
60      /** Uses Color.white as the background color, and the
61       *  name of the Container's class as the JFrame title.
62       */
63  
64      public static JFrame openInJFrame(Container content,
65                                        int width,
66                                        int height) {
67          return openInJFrame(content, width, height, content.getClass().getName(), SystemColor.window);
68      }
69  }