KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > gui > IzPackMetalTheme


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.izforge.izpack.gui;
21
22 import java.awt.Font JavaDoc;
23
24 import javax.swing.plaf.ColorUIResource JavaDoc;
25 import javax.swing.plaf.FontUIResource JavaDoc;
26 import javax.swing.plaf.metal.DefaultMetalTheme JavaDoc;
27
28 /**
29  * The IzPack metal theme.
30  *
31  * @author Julien Ponge
32  */

33 public class IzPackMetalTheme extends DefaultMetalTheme JavaDoc
34 {
35
36     /** The fonts color. */
37     private ColorUIResource JavaDoc color;
38
39     private FontUIResource JavaDoc controlFont;
40
41     private FontUIResource JavaDoc menuFont;
42
43     private FontUIResource JavaDoc windowTitleFont;
44
45     /** The constructor. */
46     public IzPackMetalTheme()
47     {
48         color = new ColorUIResource JavaDoc(0, 0, 0);
49
50         Font JavaDoc font1 = createFont("Tahoma", Font.PLAIN, 11);
51         Font JavaDoc font2 = createFont("Tahoma", Font.BOLD, 11);
52
53         menuFont = new FontUIResource JavaDoc(font1);
54         controlFont = new FontUIResource JavaDoc(font1);
55         windowTitleFont = new FontUIResource JavaDoc(font2);
56     }
57
58     private Font JavaDoc createFont(String JavaDoc name, int style, int size)
59     {
60         Font JavaDoc font = new Font JavaDoc(name, style, size);
61         return ((font == null) ? new Font JavaDoc("Dialog", style, size) : font);
62     }
63
64     /**
65      * Returns the color.
66      *
67      * @return The color.
68      */

69     public ColorUIResource JavaDoc getControlTextColor()
70     {
71         return color;
72     }
73
74     /**
75      * Returns the color.
76      *
77      * @return The color.
78      */

79     public ColorUIResource JavaDoc getMenuTextColor()
80     {
81         return color;
82     }
83
84     /**
85      * Returns the color.
86      *
87      * @return The color.
88      */

89     public ColorUIResource JavaDoc getSystemTextColor()
90     {
91         return color;
92     }
93
94     /**
95      * Returns the color.
96      *
97      * @return The color.
98      */

99     public ColorUIResource JavaDoc getUserTextColor()
100     {
101         return color;
102     }
103
104     /**
105      * The Font of Labels in many cases
106      */

107     public FontUIResource JavaDoc getControlTextFont()
108     {
109         return controlFont;
110     }
111
112     /**
113      * The Font of Menus and MenuItems
114      */

115     public FontUIResource JavaDoc getMenuTextFont()
116     {
117         return menuFont;
118     }
119
120     /**
121      * The Font of Nodes in JTrees
122      */

123     public FontUIResource JavaDoc getSystemTextFont()
124     {
125         return controlFont;
126     }
127
128     /**
129      * The Font in TextFields, EditorPanes, etc.
130      */

131     public FontUIResource JavaDoc getUserTextFont()
132     {
133         return controlFont;
134     }
135
136     /**
137      * The Font of the Title of JInternalFrames
138      */

139     public FontUIResource JavaDoc getWindowTitleFont()
140     {
141         return windowTitleFont;
142     }
143
144 }
145
Popular Tags