KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > winxp > XPLFCustoms


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.swing.plaf.winxp;
21
22 import javax.swing.UIManager JavaDoc;
23 import javax.swing.plaf.ColorUIResource JavaDoc;
24 import org.netbeans.swing.plaf.LFCustoms;
25 import org.netbeans.swing.plaf.util.GuaranteedValue;
26 import org.netbeans.swing.plaf.util.UIBootstrapValue;
27 import org.netbeans.swing.plaf.util.UIUtils;
28
29 import javax.swing.*;
30 import javax.swing.border.EmptyBorder JavaDoc;
31 import javax.swing.border.MatteBorder JavaDoc;
32 import java.awt.*;
33 import java.util.logging.Level JavaDoc;
34 import java.util.logging.Logger JavaDoc;
35 import java.util.ResourceBundle JavaDoc;
36
37
38 /** Default system-provided customizer for Windows XP LF
39  * Public only to be accessible by ProxyLazyValue, please don't abuse.
40  */

41 public final class XPLFCustoms extends LFCustoms {
42     private static final String JavaDoc TAB_FOCUS_FILL_DARK = "tab_focus_fill_dark"; //NOI18N
43
private static final String JavaDoc TAB_FOCUS_FILL_BRIGHT = "tab_focus_fill_bright"; //NOI18N
44
private static final String JavaDoc TAB_UNSEL_FILL_DARK = "tab_unsel_fill_dark"; //NOI18N
45
private static final String JavaDoc TAB_UNSEL_FILL_BRIGHT = "tab_unsel_fill_bright"; //NOI18N
46
private static final String JavaDoc TAB_SEL_FILL = "tab_sel_fill"; //NOI18N
47
private static final String JavaDoc TAB_SEL_FILL_BRIGHT = "tab_sel_fill_bright"; //NOI18N
48
private static final String JavaDoc TAB_SEL_FILL_DARK = "tab_sel_fill_dark"; //NOI18N
49
private static final String JavaDoc TAB_BORDER = "tab_border"; //NOI18N
50
private static final String JavaDoc TAB_BOTTOM_BORDER = "tab_bottom_border"; //NOI18N
51
private static final String JavaDoc TAB_SEL_BORDER = "tab_sel_border"; //NOI18N
52
private static final String JavaDoc TAB_HIGHLIGHT_HEADER = "tab_highlight_header"; //NOI18N
53
private static final String JavaDoc TAB_HIGHLIGHT_HEADER_FILL = "tab_highlight_header_fill"; //NOI18N
54
private static final String JavaDoc STANDARD_BORDER = "standard_border"; //NOI18N
55
private static final String JavaDoc TAB_CLOSE_BUTTON = "close_button"; //NOI18N
56
private static final String JavaDoc TAB_CLOSE_BUTTON_HIGHLIGHT = "close_button_highlight"; //NOI18N
57
private static final String JavaDoc TAB_CLOSE_BUTTON_BORDER_FOCUS = "close_button_border_focus"; //NOI18N
58
private static final String JavaDoc TAB_CLOSE_BUTTON_BORDER_SELECTED = "close_button_border_selected"; //NOI18N
59
private static final String JavaDoc TAB_CLOSE_BUTTON_BORDER_UNSEL = "close_button_border_unsel"; //NOI18N
60
private static final String JavaDoc TAB_SEL_BOTTOM_BORDER = "tab_sel_bottom_border"; //NOI18N
61

62     static final String JavaDoc SCROLLPANE_BORDER_COLOR = "scrollpane_border"; //NOI18N
63

64     public Object JavaDoc[] createLookAndFeelCustomizationKeysAndValues() {
65         int fontsize = 11;
66         Integer JavaDoc in = (Integer JavaDoc) UIManager.get(CUSTOM_FONT_SIZE); //NOI18N
67
if (in != null) {
68             fontsize = in.intValue();
69         }
70         
71         Object JavaDoc[] result = new Object JavaDoc[] {
72                 //Work around a bug in windows which sets the text area font to
73
//"MonoSpaced", causing all accessible dialogs to have monospaced text
74
"TextArea.font", new GuaranteedValue ("Label.font", new Font("Dialog", Font.PLAIN, fontsize)),
75                 
76                 EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS, new Insets(17, 0, 17, 0),
77             };
78             
79         tahomaWarning();
80             
81         return result;
82     }
83
84     public Object JavaDoc[] createApplicationSpecificKeysAndValues () {
85         UIBootstrapValue editorTabsUI = new XPEditorColorings (
86                 "org.netbeans.swing.tabcontrol.plaf.WinXPEditorTabDisplayerUI");
87
88         Object JavaDoc viewTabsUI = editorTabsUI.createShared("org.netbeans.swing.tabcontrol.plaf.WinXPViewTabDisplayerUI");
89
90         Image explorerIcon = UIUtils.loadImage("org/netbeans/swing/plaf/resources/xp-explorer-folder.gif");
91
92         Object JavaDoc propertySheetValues = new XPPropertySheetColorings();
93
94         Object JavaDoc[] uiDefaults = {
95             EDITOR_TAB_DISPLAYER_UI, editorTabsUI,
96             VIEW_TAB_DISPLAYER_UI, viewTabsUI,
97             
98             DESKTOP_BACKGROUND, new Color(226, 223, 214), //NOI18N
99
SCROLLPANE_BORDER_COLOR, new Color(127, 157, 185),
100             DESKTOP_BORDER, new EmptyBorder JavaDoc(6, 5, 4, 6),
101             SCROLLPANE_BORDER, UIManager.get("ScrollPane.border"),
102             EXPLORER_STATUS_BORDER, new StatusLineBorder(StatusLineBorder.TOP),
103             EXPLORER_FOLDER_ICON , explorerIcon,
104             EXPLORER_FOLDER_OPENED_ICON, explorerIcon,
105             EDITOR_STATUS_LEFT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
106             EDITOR_STATUS_RIGHT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
107             EDITOR_STATUS_INNER_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
108             EDITOR_STATUS_ONLYONEBORDER, new StatusLineBorder(StatusLineBorder.TOP),
109             EDITOR_TOOLBAR_BORDER, new EditorToolbarBorder(),
110             OUTPUT_SELECTION_BACKGROUND, new Color (164, 180, 255),
111
112             PROPERTYSHEET_BOOTSTRAP, propertySheetValues,
113
114             WORKPLACE_FILL, new Color(226, 223, 214),
115
116             DESKTOP_SPLITPANE_BORDER, BorderFactory.createEmptyBorder(4, 0, 0, 0),
117             SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.WinXPSlidingButtonUI",
118
119             // progress component related
120
"nbProgressBar.Foreground", new Color(49, 106, 197),
121             "nbProgressBar.Background", Color.WHITE,
122             "nbProgressBar.popupDynaText.foreground", new Color(141, 136, 122),
123             "nbProgressBar.popupText.background", new Color(249, 249, 249),
124             "nbProgressBar.popupText.foreground", UIManager.getColor("TextField.foreground"),
125             "nbProgressBar.popupText.selectBackground", UIManager.getColor("List.selectionBackground"),
126             "nbProgressBar.popupText.selectForeground", UIManager.getColor("List.selectionForeground"),
127             PROGRESS_CANCEL_BUTTON_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_xp.png")
128
129         }; //NOI18N
130

131         //Workaround for JDK 1.5.0 bug 5080144 - Disabled JTextFields stay white
132
//XPTheme uses Color instead of ColorUIResource
133
convert ("TextField.background"); //NOI18N
134
convert ("TextField.inactiveBackground"); //NOI18N
135
convert ("TextField.disabledBackground"); //NOI18N
136

137         return uiDefaults;
138     }
139     
140     /**
141      * Takes a UIManager color key and ensures that it is stored as a
142      * ColorUIResource, not a Color.
143      */

144     private static final void convert (String JavaDoc key) {
145         Color c = UIManager.getColor(key);
146         if (c != null && !(c instanceof ColorUIResource JavaDoc)) {
147             UIManager.put (key, new ColorUIResource JavaDoc(c));
148         }
149     }
150     
151     protected Object JavaDoc[] additionalKeys() {
152         Object JavaDoc[] kv = new XPEditorColorings("").createKeysAndValues();
153         Object JavaDoc[] kv2 = new XPPropertySheetColorings().createKeysAndValues();
154         Object JavaDoc[] result = new Object JavaDoc[(kv.length / 2) + (kv2.length / 2)];
155         int ct = 0;
156         for (int i=0; i < kv.length; i+=2) {
157             result[ct] = kv[i];
158             ct++;
159         }
160         for (int i=0; i < kv2.length; i+=2) {
161             result[ct] = kv2[i];
162             ct++;
163         }
164         return result;
165     }
166
167     /** Prints warning of JDK bug if jdk 1.5.0 or 1.5.0_01 is used -
168      * fonts aren't set to Tahoma, which looks bad.
169      */

170     private void tahomaWarning () {
171         String JavaDoc version = System.getProperty("java.version");
172         if ("1.5.0".equals(version) || version.startsWith("1.5.0_01")) {
173             Logger.getLogger(XPLFCustoms.class.getName()).log(Level.WARNING,
174                     ResourceBundle.getBundle("org.netbeans.swing.plaf.winxp.Bundle").getString("MSG_TahomaWarning"));
175         }
176     }
177     
178     
179     private class XPEditorColorings extends UIBootstrapValue.Lazy {
180         public XPEditorColorings (String JavaDoc name) {
181             super (name);
182         }
183
184         public Object JavaDoc[] createKeysAndValues() {
185             return new Object JavaDoc[] {
186             //Tab control - XXX REPLACE WITH RelativeColor - need to figure out base
187
//colors for each color
188
TAB_FOCUS_FILL_DARK, new Color(210, 220, 243),
189             TAB_FOCUS_FILL_BRIGHT, new Color(238, 242, 253),
190             TAB_UNSEL_FILL_DARK, new Color(236, 235, 229),
191             TAB_UNSEL_FILL_BRIGHT, new Color(252,251,246),
192             TAB_SEL_FILL, Color.white,
193             TAB_SEL_FILL_BRIGHT, Color.white,
194             TAB_SEL_FILL_DARK, new Color(243, 241, 224),
195             TAB_BORDER, new Color(145, 167, 180),
196             TAB_BOTTOM_BORDER, new Color(127, 157, 185),
197             TAB_SEL_BORDER, new Color(145, 155, 156),
198             TAB_HIGHLIGHT_HEADER, new Color(230, 139, 44),
199             TAB_HIGHLIGHT_HEADER_FILL, new Color(255, 199, 60),
200             STANDARD_BORDER, new Color(127, 157, 185),
201             TAB_CLOSE_BUTTON, Color.black,
202             TAB_CLOSE_BUTTON_HIGHLIGHT, new Color(172,57,28),
203             TAB_CLOSE_BUTTON_BORDER_FOCUS, new Color(181,201,243),
204             TAB_CLOSE_BUTTON_BORDER_SELECTED, new Color(203,202,187),
205             TAB_CLOSE_BUTTON_BORDER_UNSEL, new Color(200,201,192),
206             TAB_SEL_BOTTOM_BORDER, new Color(238,235,218),
207
208             //Borders for the tab control
209
EDITOR_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
210             EDITOR_TAB_CONTENT_BORDER,
211                 new MatteBorder JavaDoc(0, 1, 1, 1, new Color(127, 157, 185)),
212             EDITOR_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),
213
214             VIEW_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
215             VIEW_TAB_CONTENT_BORDER,
216                 new MatteBorder JavaDoc(0, 1, 1, 1, new Color(127, 157, 185)),
217             VIEW_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),
218             };
219         }
220     }
221
222     private class XPPropertySheetColorings extends UIBootstrapValue.Lazy {
223         public XPPropertySheetColorings () {
224             super ("propertySheet"); //NOI18N
225
}
226
227         public Object JavaDoc[] createKeysAndValues() {
228             return new Object JavaDoc[] {
229                 PROPSHEET_SET_BACKGROUND, new Color(49,106,197),
230                 PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
231                 PROPSHEET_SET_BACKGROUND, new Color(212,208,200),
232                 PROPSHEET_SET_FOREGROUND, Color.BLACK,
233                 PROPSHEET_SELECTED_SET_BACKGROUND, new Color(49,106,197),
234                 PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
235                 PROPSHEET_DISABLED_FOREGROUND, new Color(161,161,146),
236                 PROPSHEET_BUTTON_FOREGROUND, Color.BLACK,
237             };
238         }
239
240     }
241 }
242
Popular Tags