34 import javax.swing.*;
35 import javax.swing.plaf.ComponentUI;
36
37 import static com.sun.java.swing.plaf.windows.TMSchema.*;
38 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
39
40
41 /**
42 * Windows rendition of the component.
43 * <p>
44 * <strong>Warning:</strong>
45 * Serialized objects of this class will not be compatible with
46 * future Swing releases. The current serialization support is appropriate
47 * for short term storage or RMI between applications running the same
48 * version of Swing. A future release of Swing will provide support for
49 * long term persistence.
50 */
51 public class WindowsScrollBarUI extends BasicScrollBarUI {
52 private Grid thumbGrid;
53 private Grid highlightGrid;
54
55 /**
56 * Creates a UI for a JScrollBar.
57 *
58 * @param c the text field
59 * @return the UI
60 */
61 public static ComponentUI createUI(JComponent c) {
62 return new WindowsScrollBarUI();
63 }
64
65 protected void installDefaults() {
66 super.installDefaults();
67
68 if (XPStyle.getXP() != null) {
69 scrollbar.setBorder(null);
70 }
71 }
72
73 public void uninstallUI(JComponent c) {
74 super.uninstallUI(c);
75 thumbGrid = highlightGrid = null;
76 }
77
78 protected void configureScrollBarColors() {
79 super.configureScrollBarColors();
80 Color color = UIManager.getColor("ScrollBar.trackForeground");
81 if (color != null && trackColor != null) {
82 thumbGrid = Grid.getGrid(color, trackColor);
83 }
84
85 color = UIManager.getColor("ScrollBar.trackHighlightForeground");
86 if (color != null && trackHighlightColor != null) {
87 highlightGrid = Grid.getGrid(color, trackHighlightColor);
88 }
89 }
90
|
34 import javax.swing.*;
35 import javax.swing.plaf.ComponentUI;
36
37 import static com.sun.java.swing.plaf.windows.TMSchema.*;
38 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
39
40
41 /**
42 * Windows rendition of the component.
43 * <p>
44 * <strong>Warning:</strong>
45 * Serialized objects of this class will not be compatible with
46 * future Swing releases. The current serialization support is appropriate
47 * for short term storage or RMI between applications running the same
48 * version of Swing. A future release of Swing will provide support for
49 * long term persistence.
50 */
51 public class WindowsScrollBarUI extends BasicScrollBarUI {
52 private Grid thumbGrid;
53 private Grid highlightGrid;
54 private Dimension horizontalThumbSize;
55 private Dimension verticalThumbSize;
56
57 /**
58 * Creates a UI for a JScrollBar.
59 *
60 * @param c the text field
61 * @return the UI
62 */
63 public static ComponentUI createUI(JComponent c) {
64 return new WindowsScrollBarUI();
65 }
66
67 protected void installDefaults() {
68 super.installDefaults();
69
70 XPStyle xp = XPStyle.getXP();
71 if (xp != null) {
72 scrollbar.setBorder(null);
73 horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
74 verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
75 } else {
76 horizontalThumbSize = null;
77 verticalThumbSize = null;
78 }
79 }
80
81 private static Dimension getSize(Component component, XPStyle xp, Part part) {
82 Skin skin = xp.getSkin(component, part);
83 return new Dimension(skin.getWidth(), skin.getHeight());
84 }
85
86 @Override
87 protected Dimension getMinimumThumbSize() {
88 if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
89 return super.getMinimumThumbSize();
90 }
91 return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
92 ? horizontalThumbSize
93 : verticalThumbSize;
94 }
95
96 public void uninstallUI(JComponent c) {
97 super.uninstallUI(c);
98 thumbGrid = highlightGrid = null;
99 }
100
101 protected void configureScrollBarColors() {
102 super.configureScrollBarColors();
103 Color color = UIManager.getColor("ScrollBar.trackForeground");
104 if (color != null && trackColor != null) {
105 thumbGrid = Grid.getGrid(color, trackColor);
106 }
107
108 color = UIManager.getColor("ScrollBar.trackHighlightForeground");
109 if (color != null && trackHighlightColor != null) {
110 highlightGrid = Grid.getGrid(color, trackHighlightColor);
111 }
112 }
113
|