KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > Looks


1 /*
2  * (c) Rob Gordon 2005.
3  */

4 package org.oddjob.designer;
5
6 import java.awt.Component JavaDoc;
7 import java.awt.Font JavaDoc;
8 import java.awt.GridBagConstraints JavaDoc;
9 import java.awt.GridBagLayout JavaDoc;
10 import java.awt.Insets JavaDoc;
11
12 import javax.swing.JLabel JavaDoc;
13 import javax.swing.JPanel JavaDoc;
14 import javax.swing.SwingConstants JavaDoc;
15 import javax.swing.border.Border JavaDoc;
16 import javax.swing.border.CompoundBorder JavaDoc;
17 import javax.swing.border.EmptyBorder JavaDoc;
18 import javax.swing.border.TitledBorder JavaDoc;
19
20 /**
21  * Provide some components and dimensions with a standard look and feel.
22  */

23
24 public class Looks{
25     
26     public static final int DESIGNER_TREE_WIDTH = 200;
27     public static final int DETAIL_FORM_WIDTH = 400;
28     public static final int DETAIL_FORM_BORDER = 4;
29     public static final int GROUP_BORDER = 3;
30     
31     public static final int DETAIL_USABLE_WIDTH = DETAIL_FORM_WIDTH
32             - 2 * GROUP_BORDER- 2 * DETAIL_FORM_BORDER;
33     
34     public static final int TEXT_FIELD_SIZE = 24;
35     public static final int LABEL_SIZE = 20;
36     
37     public static final int LIST_ROWS = 8;
38     
39     public static final int DESIGNER_HEIGHT = 380;
40     public static final int DESIGNER_WIDTH
41             = DESIGNER_TREE_WIDTH + DETAIL_FORM_WIDTH;
42     
43     /**
44      * Create a standard looking border.
45      *
46      * @param title The border title.
47      * @return The border.
48      */

49     public static Border JavaDoc groupBorder(String JavaDoc title) {
50         return new CompoundBorder JavaDoc(new TitledBorder JavaDoc(title),
51                 new EmptyBorder JavaDoc(GROUP_BORDER, GROUP_BORDER, GROUP_BORDER, GROUP_BORDER));
52     }
53     
54     /**
55      * Create the title panel with the type name for the top of
56      * the detail form.
57      */

58     public static Component JavaDoc typePanel(String JavaDoc tag) {
59         JPanel JavaDoc typePanel = new JPanel JavaDoc(new GridBagLayout JavaDoc());
60         
61         GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
62         c.weightx = 1.0;
63         c.weighty = 0.0;
64         c.fill = GridBagConstraints.HORIZONTAL;
65         c.anchor = GridBagConstraints.NORTHWEST;
66         c.insets = new Insets JavaDoc(4, 4, 4, 4);
67         
68         typePanel.setBorder(Looks.groupBorder("Type"));
69         JLabel JavaDoc typeLabel = new JLabel JavaDoc(tag, SwingConstants.CENTER);
70         typeLabel.setFont(typeLabel.getFont()
71                 .deriveFont(Font.BOLD, typeLabel.getFont().getSize() * 1.1F));
72         typePanel.add(typeLabel, c);
73         return typePanel;
74     }
75     
76 }
77
Popular Tags