author | aghaisas |
Thu, 19 May 2016 16:45:58 +0530 | |
changeset 38985 | 2c576be3968c |
parent 37698 | 4d798c873df0 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
38985
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
2 |
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.plaf.synth; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.beans.*; |
|
30 |
import javax.swing.*; |
|
31 |
import javax.swing.plaf.*; |
|
32 |
import javax.swing.plaf.basic.*; |
|
33 |
||
34 |
||
35 |
/** |
|
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
36 |
* Provides the Synth L&F UI delegate for |
4394 | 37 |
* {@link javax.swing.JScrollBar}. |
2 | 38 |
* |
39 |
* @author Scott Violet |
|
4394 | 40 |
* @since 1.7 |
2 | 41 |
*/ |
4394 | 42 |
public class SynthScrollBarUI extends BasicScrollBarUI |
43 |
implements PropertyChangeListener, SynthUI { |
|
2 | 44 |
|
45 |
private SynthStyle style; |
|
46 |
private SynthStyle thumbStyle; |
|
47 |
private SynthStyle trackStyle; |
|
48 |
||
49 |
private boolean validMinimumThumbSize; |
|
50 |
||
29894
3e16b51732f5
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents:
25859
diff
changeset
|
51 |
/** |
3e16b51732f5
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents:
25859
diff
changeset
|
52 |
* Returns a UI. |
3e16b51732f5
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents:
25859
diff
changeset
|
53 |
* @return a UI |
3e16b51732f5
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents:
25859
diff
changeset
|
54 |
* @param c a component |
3e16b51732f5
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents:
25859
diff
changeset
|
55 |
*/ |
2 | 56 |
public static ComponentUI createUI(JComponent c) { |
57 |
return new SynthScrollBarUI(); |
|
58 |
} |
|
59 |
||
4394 | 60 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
61 |
* {@inheritDoc} |
4394 | 62 |
*/ |
63 |
@Override |
|
2 | 64 |
protected void installDefaults() { |
16463
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
7668
diff
changeset
|
65 |
super.installDefaults(); |
2 | 66 |
trackHighlight = NO_HIGHLIGHT; |
67 |
if (scrollbar.getLayout() == null || |
|
68 |
(scrollbar.getLayout() instanceof UIResource)) { |
|
69 |
scrollbar.setLayout(this); |
|
70 |
} |
|
4966
ff6769741ba1
6924059: SynthScrollBarUI.configureScrollBarColors() should have spec different from the overridden method
rupashka
parents:
4848
diff
changeset
|
71 |
configureScrollBarColors(); |
2 | 72 |
updateStyle(scrollbar); |
73 |
} |
|
74 |
||
4394 | 75 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
76 |
* {@inheritDoc} |
4394 | 77 |
*/ |
78 |
@Override |
|
2 | 79 |
protected void configureScrollBarColors() { |
80 |
} |
|
81 |
||
82 |
private void updateStyle(JScrollBar c) { |
|
83 |
SynthStyle oldStyle = style; |
|
84 |
SynthContext context = getContext(c, ENABLED); |
|
85 |
style = SynthLookAndFeel.updateStyle(context, this); |
|
86 |
if (style != oldStyle) { |
|
87 |
scrollBarWidth = style.getInt(context,"ScrollBar.thumbHeight", 14); |
|
88 |
minimumThumbSize = (Dimension)style.get(context, |
|
89 |
"ScrollBar.minimumThumbSize"); |
|
90 |
if (minimumThumbSize == null) { |
|
91 |
minimumThumbSize = new Dimension(); |
|
92 |
validMinimumThumbSize = false; |
|
93 |
} |
|
94 |
else { |
|
95 |
validMinimumThumbSize = true; |
|
96 |
} |
|
97 |
maximumThumbSize = (Dimension)style.get(context, |
|
98 |
"ScrollBar.maximumThumbSize"); |
|
99 |
if (maximumThumbSize == null) { |
|
100 |
maximumThumbSize = new Dimension(4096, 4097); |
|
101 |
} |
|
2658 | 102 |
|
103 |
incrGap = style.getInt(context, "ScrollBar.incrementButtonGap", 0); |
|
104 |
decrGap = style.getInt(context, "ScrollBar.decrementButtonGap", 0); |
|
105 |
||
106 |
// handle scaling for sizeVarients for special case components. The |
|
107 |
// key "JComponent.sizeVariant" scales for large/small/mini |
|
108 |
// components are based on Apples LAF |
|
109 |
String scaleKey = (String)scrollbar.getClientProperty( |
|
110 |
"JComponent.sizeVariant"); |
|
111 |
if (scaleKey != null){ |
|
112 |
if ("large".equals(scaleKey)){ |
|
113 |
scrollBarWidth *= 1.15; |
|
114 |
incrGap *= 1.15; |
|
115 |
decrGap *= 1.15; |
|
116 |
} else if ("small".equals(scaleKey)){ |
|
117 |
scrollBarWidth *= 0.857; |
|
118 |
incrGap *= 0.857; |
|
119 |
decrGap *= 0.857; |
|
120 |
} else if ("mini".equals(scaleKey)){ |
|
121 |
scrollBarWidth *= 0.714; |
|
122 |
incrGap *= 0.714; |
|
123 |
decrGap *= 0.714; |
|
124 |
} |
|
125 |
} |
|
126 |
||
2 | 127 |
if (oldStyle != null) { |
128 |
uninstallKeyboardActions(); |
|
129 |
installKeyboardActions(); |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
context = getContext(c, Region.SCROLL_BAR_TRACK, ENABLED); |
|
134 |
trackStyle = SynthLookAndFeel.updateStyle(context, this); |
|
135 |
||
136 |
context = getContext(c, Region.SCROLL_BAR_THUMB, ENABLED); |
|
137 |
thumbStyle = SynthLookAndFeel.updateStyle(context, this); |
|
138 |
} |
|
139 |
||
4394 | 140 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
141 |
* {@inheritDoc} |
4394 | 142 |
*/ |
143 |
@Override |
|
2 | 144 |
protected void installListeners() { |
145 |
super.installListeners(); |
|
146 |
scrollbar.addPropertyChangeListener(this); |
|
147 |
} |
|
148 |
||
4394 | 149 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
150 |
* {@inheritDoc} |
4394 | 151 |
*/ |
152 |
@Override |
|
2 | 153 |
protected void uninstallListeners() { |
154 |
super.uninstallListeners(); |
|
155 |
scrollbar.removePropertyChangeListener(this); |
|
156 |
} |
|
157 |
||
4394 | 158 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
159 |
* {@inheritDoc} |
4394 | 160 |
*/ |
161 |
@Override |
|
2 | 162 |
protected void uninstallDefaults(){ |
163 |
SynthContext context = getContext(scrollbar, ENABLED); |
|
164 |
style.uninstallDefaults(context); |
|
165 |
style = null; |
|
166 |
||
167 |
context = getContext(scrollbar, Region.SCROLL_BAR_TRACK, ENABLED); |
|
168 |
trackStyle.uninstallDefaults(context); |
|
169 |
trackStyle = null; |
|
170 |
||
171 |
context = getContext(scrollbar, Region.SCROLL_BAR_THUMB, ENABLED); |
|
172 |
thumbStyle.uninstallDefaults(context); |
|
173 |
thumbStyle = null; |
|
174 |
||
175 |
super.uninstallDefaults(); |
|
176 |
} |
|
177 |
||
4394 | 178 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
179 |
* {@inheritDoc} |
4394 | 180 |
*/ |
181 |
@Override |
|
2 | 182 |
public SynthContext getContext(JComponent c) { |
4394 | 183 |
return getContext(c, SynthLookAndFeel.getComponentState(c)); |
2 | 184 |
} |
185 |
||
186 |
private SynthContext getContext(JComponent c, int state) { |
|
25100 | 187 |
return SynthContext.getContext(c, style, state); |
2 | 188 |
} |
189 |
||
190 |
private SynthContext getContext(JComponent c, Region region) { |
|
191 |
return getContext(c, region, getComponentState(c, region)); |
|
192 |
} |
|
193 |
||
194 |
private SynthContext getContext(JComponent c, Region region, int state) { |
|
195 |
SynthStyle style = trackStyle; |
|
196 |
||
197 |
if (region == Region.SCROLL_BAR_THUMB) { |
|
198 |
style = thumbStyle; |
|
199 |
} |
|
25100 | 200 |
return SynthContext.getContext(c, region, style, state); |
2 | 201 |
} |
202 |
||
203 |
private int getComponentState(JComponent c, Region region) { |
|
38985
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
204 |
if (region == Region.SCROLL_BAR_THUMB && c.isEnabled()) { |
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
205 |
if (isDragging) { |
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
206 |
return PRESSED; |
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
207 |
} else if (isThumbRollover()) { |
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
208 |
return MOUSE_OVER; |
2c576be3968c
7172750: Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked
aghaisas
parents:
37698
diff
changeset
|
209 |
} |
2 | 210 |
} |
211 |
return SynthLookAndFeel.getComponentState(c); |
|
212 |
} |
|
213 |
||
4394 | 214 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
215 |
* {@inheritDoc} |
4394 | 216 |
*/ |
217 |
@Override |
|
2 | 218 |
public boolean getSupportsAbsolutePositioning() { |
219 |
SynthContext context = getContext(scrollbar); |
|
220 |
boolean value = style.getBoolean(context, |
|
221 |
"ScrollBar.allowsAbsolutePositioning", false); |
|
222 |
return value; |
|
223 |
} |
|
224 |
||
4394 | 225 |
/** |
4848
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
226 |
* Notifies this UI delegate to repaint the specified component. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
227 |
* This method paints the component background, then calls |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
228 |
* the {@link #paint(SynthContext,Graphics)} method. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
229 |
* |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
230 |
* <p>In general, this method does not need to be overridden by subclasses. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
231 |
* All Look and Feel rendering code should reside in the {@code paint} method. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
232 |
* |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
233 |
* @param g the {@code Graphics} object used for painting |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
234 |
* @param c the component being painted |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
235 |
* @see #paint(SynthContext,Graphics) |
4394 | 236 |
*/ |
237 |
@Override |
|
2 | 238 |
public void update(Graphics g, JComponent c) { |
239 |
SynthContext context = getContext(c); |
|
240 |
||
241 |
SynthLookAndFeel.update(context, g); |
|
242 |
context.getPainter().paintScrollBarBackground(context, |
|
243 |
g, 0, 0, c.getWidth(), c.getHeight(), |
|
244 |
scrollbar.getOrientation()); |
|
245 |
paint(context, g); |
|
246 |
} |
|
247 |
||
4394 | 248 |
/** |
4848
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
249 |
* Paints the specified component according to the Look and Feel. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
250 |
* <p>This method is not used by Synth Look and Feel. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
251 |
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method. |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
252 |
* |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
253 |
* @param g the {@code Graphics} object used for painting |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
254 |
* @param c the component being painted |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
255 |
* @see #paint(SynthContext,Graphics) |
4394 | 256 |
*/ |
257 |
@Override |
|
2 | 258 |
public void paint(Graphics g, JComponent c) { |
259 |
SynthContext context = getContext(c); |
|
260 |
||
261 |
paint(context, g); |
|
262 |
} |
|
263 |
||
4394 | 264 |
/** |
265 |
* Paints the specified component. |
|
266 |
* |
|
267 |
* @param context context for the component being painted |
|
4848
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
268 |
* @param g the {@code Graphics} object used for painting |
ffcc849b9351
6912118: Incosistency in several SynthUI classes between inherited specs ofupdate() and paint() methods
peterz
parents:
4394
diff
changeset
|
269 |
* @see #update(Graphics,JComponent) |
4394 | 270 |
*/ |
2 | 271 |
protected void paint(SynthContext context, Graphics g) { |
272 |
SynthContext subcontext = getContext(scrollbar, |
|
273 |
Region.SCROLL_BAR_TRACK); |
|
274 |
paintTrack(subcontext, g, getTrackBounds()); |
|
275 |
||
276 |
subcontext = getContext(scrollbar, Region.SCROLL_BAR_THUMB); |
|
277 |
paintThumb(subcontext, g, getThumbBounds()); |
|
278 |
} |
|
279 |
||
4394 | 280 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
281 |
* {@inheritDoc} |
4394 | 282 |
*/ |
283 |
@Override |
|
2 | 284 |
public void paintBorder(SynthContext context, Graphics g, int x, |
285 |
int y, int w, int h) { |
|
286 |
context.getPainter().paintScrollBarBorder(context, g, x, y, w, h, |
|
287 |
scrollbar.getOrientation()); |
|
288 |
} |
|
289 |
||
4394 | 290 |
/** |
291 |
* Paints the scrollbar track. |
|
292 |
* |
|
293 |
* @param context context for the component being painted |
|
294 |
* @param g {@code Graphics} object used for painting |
|
295 |
* @param trackBounds bounding box for the track |
|
296 |
*/ |
|
297 |
protected void paintTrack(SynthContext context, Graphics g, |
|
2 | 298 |
Rectangle trackBounds) { |
4394 | 299 |
SynthLookAndFeel.updateSubregion(context, g, trackBounds); |
300 |
context.getPainter().paintScrollBarTrackBackground(context, g, trackBounds.x, |
|
2 | 301 |
trackBounds.y, trackBounds.width, trackBounds.height, |
302 |
scrollbar.getOrientation()); |
|
4394 | 303 |
context.getPainter().paintScrollBarTrackBorder(context, g, trackBounds.x, |
2 | 304 |
trackBounds.y, trackBounds.width, trackBounds.height, |
305 |
scrollbar.getOrientation()); |
|
306 |
} |
|
307 |
||
4394 | 308 |
/** |
309 |
* Paints the scrollbar thumb. |
|
310 |
* |
|
311 |
* @param context context for the component being painted |
|
312 |
* @param g {@code Graphics} object used for painting |
|
313 |
* @param thumbBounds bounding box for the thumb |
|
314 |
*/ |
|
315 |
protected void paintThumb(SynthContext context, Graphics g, |
|
2 | 316 |
Rectangle thumbBounds) { |
4394 | 317 |
SynthLookAndFeel.updateSubregion(context, g, thumbBounds); |
2 | 318 |
int orientation = scrollbar.getOrientation(); |
4394 | 319 |
context.getPainter().paintScrollBarThumbBackground(context, g, thumbBounds.x, |
2 | 320 |
thumbBounds.y, thumbBounds.width, thumbBounds.height, |
321 |
orientation); |
|
4394 | 322 |
context.getPainter().paintScrollBarThumbBorder(context, g, thumbBounds.x, |
2 | 323 |
thumbBounds.y, thumbBounds.width, thumbBounds.height, |
324 |
orientation); |
|
325 |
} |
|
326 |
||
327 |
/** |
|
328 |
* A vertical scrollbar's preferred width is the maximum of |
|
329 |
* preferred widths of the (non <code>null</code>) |
|
330 |
* increment/decrement buttons, |
|
331 |
* and the minimum width of the thumb. The preferred height is the |
|
332 |
* sum of the preferred heights of the same parts. The basis for |
|
333 |
* the preferred size of a horizontal scrollbar is similar. |
|
334 |
* <p> |
|
335 |
* The <code>preferredSize</code> is only computed once, subsequent |
|
336 |
* calls to this method just return a cached size. |
|
337 |
* |
|
338 |
* @param c the <code>JScrollBar</code> that's delegating this method to us |
|
339 |
* @return the preferred size of a Basic JScrollBar |
|
340 |
* @see #getMaximumSize |
|
341 |
* @see #getMinimumSize |
|
342 |
*/ |
|
4394 | 343 |
@Override |
2 | 344 |
public Dimension getPreferredSize(JComponent c) { |
345 |
Insets insets = c.getInsets(); |
|
346 |
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) |
|
347 |
? new Dimension(scrollBarWidth + insets.left + insets.right, 48) |
|
348 |
: new Dimension(48, scrollBarWidth + insets.top + insets.bottom); |
|
349 |
} |
|
350 |
||
4394 | 351 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
352 |
* {@inheritDoc} |
4394 | 353 |
*/ |
354 |
@Override |
|
2 | 355 |
protected Dimension getMinimumThumbSize() { |
356 |
if (!validMinimumThumbSize) { |
|
357 |
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { |
|
358 |
minimumThumbSize.width = scrollBarWidth; |
|
359 |
minimumThumbSize.height = 7; |
|
360 |
} else { |
|
361 |
minimumThumbSize.width = 7; |
|
362 |
minimumThumbSize.height = scrollBarWidth; |
|
363 |
} |
|
364 |
} |
|
365 |
return minimumThumbSize; |
|
366 |
} |
|
367 |
||
4394 | 368 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
369 |
* {@inheritDoc} |
4394 | 370 |
*/ |
371 |
@Override |
|
2 | 372 |
protected JButton createDecreaseButton(int orientation) { |
23697 | 373 |
@SuppressWarnings("serial") // anonymous class |
2658 | 374 |
SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) { |
375 |
@Override |
|
376 |
public boolean contains(int x, int y) { |
|
377 |
if (decrGap < 0) { //there is an overlap between the track and button |
|
378 |
int width = getWidth(); |
|
379 |
int height = getHeight(); |
|
380 |
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { |
|
381 |
//adjust the height by decrGap |
|
382 |
//Note: decrGap is negative! |
|
383 |
height += decrGap; |
|
384 |
} else { |
|
385 |
//adjust the width by decrGap |
|
386 |
//Note: decrGap is negative! |
|
387 |
width += decrGap; |
|
388 |
} |
|
389 |
return (x >= 0) && (x < width) && (y >= 0) && (y < height); |
|
390 |
} |
|
391 |
return super.contains(x, y); |
|
392 |
} |
|
393 |
}; |
|
2 | 394 |
synthArrowButton.setName("ScrollBar.button"); |
395 |
return synthArrowButton; |
|
396 |
} |
|
397 |
||
4394 | 398 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
399 |
* {@inheritDoc} |
4394 | 400 |
*/ |
401 |
@Override |
|
2 | 402 |
protected JButton createIncreaseButton(int orientation) { |
23697 | 403 |
@SuppressWarnings("serial") // anonymous class |
2658 | 404 |
SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) { |
405 |
@Override |
|
406 |
public boolean contains(int x, int y) { |
|
407 |
if (incrGap < 0) { //there is an overlap between the track and button |
|
408 |
int width = getWidth(); |
|
409 |
int height = getHeight(); |
|
410 |
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { |
|
411 |
//adjust the height and y by incrGap |
|
412 |
//Note: incrGap is negative! |
|
413 |
height += incrGap; |
|
414 |
y += incrGap; |
|
415 |
} else { |
|
416 |
//adjust the width and x by incrGap |
|
417 |
//Note: incrGap is negative! |
|
418 |
width += incrGap; |
|
419 |
x += incrGap; |
|
420 |
} |
|
421 |
return (x >= 0) && (x < width) && (y >= 0) && (y < height); |
|
422 |
} |
|
423 |
return super.contains(x, y); |
|
424 |
} |
|
425 |
}; |
|
2 | 426 |
synthArrowButton.setName("ScrollBar.button"); |
427 |
return synthArrowButton; |
|
428 |
} |
|
429 |
||
4394 | 430 |
/** |
20168
137788883a22
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth
alexsch
parents:
16463
diff
changeset
|
431 |
* {@inheritDoc} |
4394 | 432 |
*/ |
433 |
@Override |
|
2 | 434 |
protected void setThumbRollover(boolean active) { |
435 |
if (isThumbRollover() != active) { |
|
436 |
scrollbar.repaint(getThumbBounds()); |
|
437 |
super.setThumbRollover(active); |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
private void updateButtonDirections() { |
|
442 |
int orient = scrollbar.getOrientation(); |
|
443 |
if (scrollbar.getComponentOrientation().isLeftToRight()) { |
|
444 |
((SynthArrowButton)incrButton).setDirection( |
|
445 |
orient == HORIZONTAL? EAST : SOUTH); |
|
446 |
((SynthArrowButton)decrButton).setDirection( |
|
447 |
orient == HORIZONTAL? WEST : NORTH); |
|
448 |
} |
|
449 |
else { |
|
450 |
((SynthArrowButton)incrButton).setDirection( |
|
451 |
orient == HORIZONTAL? WEST : SOUTH); |
|
452 |
((SynthArrowButton)decrButton).setDirection( |
|
453 |
orient == HORIZONTAL ? EAST : NORTH); |
|
454 |
} |
|
455 |
} |
|
456 |
||
457 |
// |
|
458 |
// PropertyChangeListener |
|
459 |
// |
|
460 |
public void propertyChange(PropertyChangeEvent e) { |
|
461 |
String propertyName = e.getPropertyName(); |
|
462 |
||
463 |
if (SynthLookAndFeel.shouldUpdateStyle(e)) { |
|
464 |
updateStyle((JScrollBar)e.getSource()); |
|
465 |
} |
|
466 |
||
467 |
if ("orientation" == propertyName) { |
|
468 |
updateButtonDirections(); |
|
469 |
} |
|
470 |
else if ("componentOrientation" == propertyName) { |
|
471 |
updateButtonDirections(); |
|
472 |
} |
|
473 |
} |
|
474 |
} |