35 * <code>JComponent</code>s may also produce unexpected results,
36 * such as the wrong colors showing up, and is generally not
37 * encouraged.
38 *
39 */
40
41 package com.sun.java.swing.plaf.windows;
42
43 import java.awt.*;
44 import java.awt.image.*;
45 import java.security.AccessController;
46 import java.util.*;
47
48 import javax.swing.*;
49 import javax.swing.border.*;
50 import javax.swing.plaf.*;
51 import javax.swing.text.JTextComponent;
52
53 import sun.awt.image.SunWritableRaster;
54 import sun.awt.windows.ThemeReader;
55 import sun.security.action.GetPropertyAction;
56 import sun.swing.CachedPainter;
57
58 import static com.sun.java.swing.plaf.windows.TMSchema.*;
59
60
61 /**
62 * Implements Windows XP Styles for the Windows Look and Feel.
63 *
64 * @author Leif Samuelsson
65 */
66 class XPStyle {
67 // Singleton instance of this class
68 private static XPStyle xp;
69
70 // Singleton instance of SkinPainter
71 private static SkinPainter skinPainter = new SkinPainter();
72
73 private static Boolean themeActive = null;
74
82 }
83
84 /** Static method for clearing the hashmap and loading the
85 * current XP style and theme
86 */
87 static synchronized void invalidateStyle() {
88 xp = null;
89 themeActive = null;
90 skinPainter.flush();
91 }
92
93 /** Get the singleton instance of this class
94 *
95 * @return the singleton instance of this class or null if XP styles
96 * are not active or if this is not Windows XP
97 */
98 static synchronized XPStyle getXP() {
99 if (themeActive == null) {
100 Toolkit toolkit = Toolkit.getDefaultToolkit();
101 themeActive =
102 (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
103 if (themeActive == null) {
104 themeActive = Boolean.FALSE;
105 }
106 if (themeActive.booleanValue()) {
107 GetPropertyAction propertyAction =
108 new GetPropertyAction("swing.noxp");
109 if (AccessController.doPrivileged(propertyAction) == null &&
110 ThemeReader.isThemed() &&
111 !(UIManager.getLookAndFeel()
112 instanceof WindowsClassicLookAndFeel)) {
113
114 xp = new XPStyle();
115 }
116 }
117 }
118 return xp;
119 }
120
121 static boolean isVista() {
122 XPStyle xp = XPStyle.getXP();
|
35 * <code>JComponent</code>s may also produce unexpected results,
36 * such as the wrong colors showing up, and is generally not
37 * encouraged.
38 *
39 */
40
41 package com.sun.java.swing.plaf.windows;
42
43 import java.awt.*;
44 import java.awt.image.*;
45 import java.security.AccessController;
46 import java.util.*;
47
48 import javax.swing.*;
49 import javax.swing.border.*;
50 import javax.swing.plaf.*;
51 import javax.swing.text.JTextComponent;
52
53 import sun.awt.image.SunWritableRaster;
54 import sun.awt.windows.ThemeReader;
55 import sun.awt.windows.WToolkit;
56 import sun.security.action.GetPropertyAction;
57 import sun.swing.CachedPainter;
58
59 import static com.sun.java.swing.plaf.windows.TMSchema.*;
60
61
62 /**
63 * Implements Windows XP Styles for the Windows Look and Feel.
64 *
65 * @author Leif Samuelsson
66 */
67 class XPStyle {
68 // Singleton instance of this class
69 private static XPStyle xp;
70
71 // Singleton instance of SkinPainter
72 private static SkinPainter skinPainter = new SkinPainter();
73
74 private static Boolean themeActive = null;
75
83 }
84
85 /** Static method for clearing the hashmap and loading the
86 * current XP style and theme
87 */
88 static synchronized void invalidateStyle() {
89 xp = null;
90 themeActive = null;
91 skinPainter.flush();
92 }
93
94 /** Get the singleton instance of this class
95 *
96 * @return the singleton instance of this class or null if XP styles
97 * are not active or if this is not Windows XP
98 */
99 static synchronized XPStyle getXP() {
100 if (themeActive == null) {
101 Toolkit toolkit = Toolkit.getDefaultToolkit();
102 themeActive =
103 (Boolean)toolkit.getDesktopProperty(WToolkit.XPSTYLE_THEME_ACTIVE);
104 if (themeActive == null) {
105 themeActive = Boolean.FALSE;
106 }
107 if (themeActive.booleanValue()) {
108 GetPropertyAction propertyAction =
109 new GetPropertyAction("swing.noxp");
110 if (AccessController.doPrivileged(propertyAction) == null &&
111 ThemeReader.isThemed() &&
112 !(UIManager.getLookAndFeel()
113 instanceof WindowsClassicLookAndFeel)) {
114
115 xp = new XPStyle();
116 }
117 }
118 }
119 return xp;
120 }
121
122 static boolean isVista() {
123 XPStyle xp = XPStyle.getXP();
|