KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > winvista > VistaLFCustoms


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.winvista;
21
22 import java.awt.GraphicsEnvironment JavaDoc;
23 import java.util.Locale JavaDoc;
24 import javax.swing.UIManager JavaDoc;
25 import javax.swing.plaf.ColorUIResource JavaDoc;
26 import javax.swing.plaf.FontUIResource JavaDoc;
27 import org.netbeans.swing.plaf.LFCustoms;
28 import org.netbeans.swing.plaf.util.GuaranteedValue;
29 import org.netbeans.swing.plaf.util.UIBootstrapValue;
30 import org.netbeans.swing.plaf.util.UIUtils;
31
32 import javax.swing.*;
33 import javax.swing.border.EmptyBorder JavaDoc;
34 import javax.swing.border.MatteBorder JavaDoc;
35 import java.awt.*;
36
37
38 /** Default system-provided customizer for Windows Vista LF
39  * Public only to be accessible by ProxyLazyValue, please don't abuse.
40  */

41 public final class VistaLFCustoms extends LFCustoms {
42     private static final String JavaDoc TAB_FOCUS_FILL_UPPER = "tab_focus_fill_upper"; //NOI18N
43
private static final String JavaDoc TAB_FOCUS_FILL_DARK_LOWER = "tab_focus_fill_dark_lower"; //NOI18N
44
private static final String JavaDoc TAB_FOCUS_FILL_BRIGHT_LOWER = "tab_focus_fill_bright_lower"; //NOI18N
45

46     private static final String JavaDoc TAB_UNSEL_FILL_DARK_UPPER = "tab_unsel_fill_dark_upper"; //NOI18N
47
private static final String JavaDoc TAB_UNSEL_FILL_BRIGHT_UPPER = "tab_unsel_fill_bright_upper"; //NOI18N
48
private static final String JavaDoc TAB_UNSEL_FILL_DARK_LOWER = "tab_unsel_fill_dark_lower"; //NOI18N
49
private static final String JavaDoc TAB_UNSEL_FILL_BRIGHT_LOWER = "tab_unsel_fill_bright_lower"; //NOI18N
50

51     private static final String JavaDoc TAB_SEL_FILL = "tab_sel_fill"; //NOI18N
52

53     private static final String JavaDoc TAB_MOUSE_OVER_FILL_BRIGHT_UPPER = "tab_mouse_over_fill_bright_upper"; //NOI18N
54
private static final String JavaDoc TAB_MOUSE_OVER_FILL_DARK_UPPER = "tab_mouse_over_fill_dark_upper"; //NOI18N
55
private static final String JavaDoc TAB_MOUSE_OVER_FILL_BRIGHT_LOWER = "tab_mouse_over_fill_bright_lower"; //NOI18N
56
private static final String JavaDoc TAB_MOUSE_OVER_FILL_DARK_LOWER = "tab_mouse_over_fill_dark_lower"; //NOI18N
57

58     private static final String JavaDoc TAB_BORDER = "tab_border"; //NOI18N
59
private static final String JavaDoc TAB_SEL_BORDER = "tab_sel_border"; //NOI18N
60
private static final String JavaDoc TAB_BORDER_INNER = "tab_border_inner"; //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         return result;
80     }
81
82     public Object JavaDoc[] createApplicationSpecificKeysAndValues () {
83         UIBootstrapValue editorTabsUI = new VistaEditorColorings (
84                 "org.netbeans.swing.tabcontrol.plaf.WinVistaEditorTabDisplayerUI");
85
86         Object JavaDoc viewTabsUI = editorTabsUI.createShared("org.netbeans.swing.tabcontrol.plaf.WinVistaViewTabDisplayerUI");
87
88         //TODO change icon (copy & paste)
89
Image explorerIcon = UIUtils.loadImage("org/netbeans/swing/plaf/resources/vista_folder.png");
90
91         Object JavaDoc propertySheetValues = new VistaPropertySheetColorings();
92
93         Object JavaDoc[] uiDefaults = {
94             EDITOR_TAB_DISPLAYER_UI, editorTabsUI,
95             VIEW_TAB_DISPLAYER_UI, viewTabsUI,
96             
97             DESKTOP_BACKGROUND, new Color(226, 223, 214), //NOI18N
98
SCROLLPANE_BORDER_COLOR, new Color(127, 157, 185),
99             DESKTOP_BORDER, new EmptyBorder JavaDoc(6, 5, 4, 6),
100             SCROLLPANE_BORDER, UIManager.get("ScrollPane.border"),
101             EXPLORER_STATUS_BORDER, new StatusLineBorder(StatusLineBorder.TOP),
102             EXPLORER_FOLDER_ICON , explorerIcon,
103             EXPLORER_FOLDER_OPENED_ICON, explorerIcon,
104             EDITOR_STATUS_LEFT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
105             EDITOR_STATUS_RIGHT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
106             EDITOR_STATUS_INNER_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
107             EDITOR_STATUS_ONLYONEBORDER, new StatusLineBorder(StatusLineBorder.TOP),
108             EDITOR_TOOLBAR_BORDER, new EditorToolbarBorder(),
109             OUTPUT_SELECTION_BACKGROUND, new Color (164, 180, 255),
110
111             PROPERTYSHEET_BOOTSTRAP, propertySheetValues,
112
113             WORKPLACE_FILL, new Color(226, 223, 214),
114
115             DESKTOP_SPLITPANE_BORDER, BorderFactory.createEmptyBorder(4, 0, 0, 0),
116             SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.WinVistaSlidingButtonUI",
117
118             // progress component related
119
"nbProgressBar.Foreground", new Color(49, 106, 197),
120             "nbProgressBar.Background", Color.WHITE,
121             "nbProgressBar.popupDynaText.foreground", new Color(115, 115, 115),
122             "nbProgressBar.popupText.background", new Color(249, 249, 249),
123             "nbProgressBar.popupText.foreground", UIManager.getColor("TextField.foreground"),
124             "nbProgressBar.popupText.selectBackground", UIManager.getColor("List.selectionBackground"),
125             "nbProgressBar.popupText.selectForeground", UIManager.getColor("List.selectionForeground"),
126             PROGRESS_CANCEL_BUTTON_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/vista_mini_close_enabled.png"),
127             PROGRESS_CANCEL_BUTTON_ROLLOVER_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/vista_mini_close_over.png"),
128             PROGRESS_CANCEL_BUTTON_PRESSED_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/vista_mini_close_pressed.png")
129
130         }; //NOI18N
131

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

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

145     private static final void convert (String JavaDoc key) {
146         Color c = UIManager.getColor(key);
147         if (c != null && !(c instanceof ColorUIResource JavaDoc)) {
148             UIManager.put (key, new ColorUIResource JavaDoc(c));
149         }
150     }
151     
152     protected Object JavaDoc[] additionalKeys() {
153         Object JavaDoc[] kv = new VistaEditorColorings("").createKeysAndValues();
154         Object JavaDoc[] kv2 = new VistaPropertySheetColorings().createKeysAndValues();
155         Object JavaDoc[] result = new Object JavaDoc[(kv.length / 2) + (kv2.length / 2)];
156         int ct = 0;
157         for (int i=0; i < kv.length; i+=2) {
158             result[ct] = kv[i];
159             ct++;
160         }
161         for (int i=0; i < kv2.length; i+=2) {
162             result[ct] = kv2[i];
163             ct++;
164         }
165         return result;
166     }
167
168     private class VistaEditorColorings extends UIBootstrapValue.Lazy {
169         public VistaEditorColorings (String JavaDoc name) {
170             super (name);
171         }
172
173         public Object JavaDoc[] createKeysAndValues() {
174             return new Object JavaDoc[] {
175             //Tab control - XXX REPLACE WITH RelativeColor - need to figure out base
176
//colors for each color
177
//selected & focused
178
TAB_FOCUS_FILL_UPPER, new Color(242, 249, 252),
179             TAB_FOCUS_FILL_BRIGHT_LOWER, new Color(225, 241, 249),
180             TAB_FOCUS_FILL_DARK_LOWER, new Color(216, 236, 246),
181             
182             //no selection, no focus
183
TAB_UNSEL_FILL_BRIGHT_UPPER, new Color(235,235,235),
184             TAB_UNSEL_FILL_DARK_UPPER, new Color(229, 229, 229),
185             TAB_UNSEL_FILL_BRIGHT_LOWER, new Color(214,214,214),
186             TAB_UNSEL_FILL_DARK_LOWER, new Color(203, 203, 203),
187             
188             //selected, no focus
189
TAB_SEL_FILL, new Color(244,244,244),
190             
191             //no selection, mouse over
192
TAB_MOUSE_OVER_FILL_BRIGHT_UPPER, new Color(223,242,252),
193             TAB_MOUSE_OVER_FILL_DARK_UPPER, new Color(214,239,252),
194             TAB_MOUSE_OVER_FILL_BRIGHT_LOWER, new Color(189,228,250),
195             TAB_MOUSE_OVER_FILL_DARK_LOWER, new Color(171,221,248),
196             
197             TAB_BORDER, new Color(137,140,149),
198             TAB_SEL_BORDER, new Color(60,127,177),
199             TAB_BORDER_INNER, new Color(255,255,255),
200
201             //Borders for the tab control
202
EDITOR_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
203             EDITOR_TAB_CONTENT_BORDER,
204                 new MatteBorder JavaDoc(0, 1, 1, 1, new Color(137, 140, 149)),
205             EDITOR_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),
206
207             VIEW_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
208             VIEW_TAB_CONTENT_BORDER,
209                 new MatteBorder JavaDoc(0, 1, 1, 1, new Color(137, 140, 149)),
210             VIEW_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),
211             };
212         }
213     }
214
215     private class VistaPropertySheetColorings extends UIBootstrapValue.Lazy {
216         public VistaPropertySheetColorings () {
217             super ("propertySheet"); //NOI18N
218
}
219
220         public Object JavaDoc[] createKeysAndValues() {
221             return new Object JavaDoc[] {
222                 PROPSHEET_SELECTION_BACKGROUND, new Color(49,106,197),
223                 PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
224                 PROPSHEET_SET_BACKGROUND, new Color(213,213,213),
225                 PROPSHEET_SET_FOREGROUND, Color.BLACK,
226                 PROPSHEET_SELECTED_SET_BACKGROUND, new Color(49,106,197),
227                 PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
228                 PROPSHEET_DISABLED_FOREGROUND, new Color(161,161,146),
229                 PROPSHEET_BUTTON_FOREGROUND, Color.BLACK,
230             };
231         }
232     }
233 }
234
Popular Tags