80 |
*/ |
*/ |
81 |
protected class ArrowButtonListener extends MouseAdapter |
protected class ArrowButtonListener extends MouseAdapter |
82 |
{ |
{ |
83 |
|
|
84 |
/** |
/** |
85 |
* Move the thumb in the direction specified by the button's arrow. If |
* Move the thumb in the direction specified by the button's arrow. If |
86 |
* this button is held down, then it should keep moving the thumb. |
* this button is held down, then it should keep moving the thumb. |
92 |
scrollTimer.stop(); |
scrollTimer.stop(); |
93 |
scrollListener.setScrollByBlock(false); |
scrollListener.setScrollByBlock(false); |
94 |
if (e.getSource() == incrButton) |
if (e.getSource() == incrButton) |
95 |
scrollListener.setDirection(POSITIVE_SCROLL); |
scrollListener.setDirection(POSITIVE_SCROLL); |
96 |
else |
else if (e.getSource() == decrButton) |
97 |
scrollListener.setDirection(NEGATIVE_SCROLL); |
scrollListener.setDirection(NEGATIVE_SCROLL); |
98 |
|
scrollTimer.setDelay(100); |
99 |
scrollTimer.start(); |
scrollTimer.start(); |
100 |
} |
} |
101 |
|
|
107 |
public void mouseReleased(MouseEvent e) |
public void mouseReleased(MouseEvent e) |
108 |
{ |
{ |
109 |
scrollTimer.stop(); |
scrollTimer.stop(); |
110 |
|
scrollTimer.setDelay(300); |
111 |
|
if (e.getSource() == incrButton) |
112 |
|
scrollByUnit(POSITIVE_SCROLL); |
113 |
|
else if (e.getSource() == decrButton) |
114 |
|
scrollByUnit(NEGATIVE_SCROLL); |
115 |
} |
} |
116 |
} |
} |
117 |
|
|
249 |
scrollbar.repaint(); |
scrollbar.repaint(); |
250 |
return; |
return; |
251 |
} |
} |
252 |
scrollByBlock(direction); |
scrollByBlock(direction); |
253 |
} |
} |
254 |
else |
else |
255 |
scrollByUnit(direction); |
scrollByUnit(direction); |
323 |
else |
else |
324 |
value = valueForYPosition(currentMouseY); |
value = valueForYPosition(currentMouseY); |
325 |
|
|
|
if (value == scrollbar.getValue()) |
|
|
return; |
|
|
|
|
326 |
if (! thumbRect.contains(e.getPoint())) |
if (! thumbRect.contains(e.getPoint())) |
327 |
{ |
{ |
328 |
scrollTimer.stop(); |
scrollTimer.stop(); |
337 |
trackHighlight = DECREASE_HIGHLIGHT; |
trackHighlight = DECREASE_HIGHLIGHT; |
338 |
scrollListener.setDirection(NEGATIVE_SCROLL); |
scrollListener.setDirection(NEGATIVE_SCROLL); |
339 |
} |
} |
340 |
|
scrollTimer.setDelay(100); |
341 |
scrollTimer.start(); |
scrollTimer.start(); |
342 |
} |
} |
343 |
else |
else |
348 |
// "lower" edge of the thumb. The value at which |
// "lower" edge of the thumb. The value at which |
349 |
// the cursor is at must be greater or equal |
// the cursor is at must be greater or equal |
350 |
// to that value. |
// to that value. |
351 |
|
|
352 |
|
scrollListener.setScrollByBlock(false); |
353 |
scrollbar.setValueIsAdjusting(true); |
scrollbar.setValueIsAdjusting(true); |
354 |
offset = value - scrollbar.getValue(); |
offset = value - scrollbar.getValue(); |
355 |
} |
} |
356 |
scrollbar.repaint(); |
scrollbar.repaint(); |
357 |
} |
} |
364 |
*/ |
*/ |
365 |
public void mouseReleased(MouseEvent e) |
public void mouseReleased(MouseEvent e) |
366 |
{ |
{ |
|
trackHighlight = NO_HIGHLIGHT; |
|
367 |
scrollTimer.stop(); |
scrollTimer.stop(); |
368 |
|
scrollTimer.setDelay(300); |
369 |
if (scrollbar.getValueIsAdjusting()) |
currentMouseX = e.getX(); |
370 |
scrollbar.setValueIsAdjusting(false); |
currentMouseY = e.getY(); |
371 |
|
|
372 |
|
int value; |
373 |
|
if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL) |
374 |
|
value = valueForXPosition(currentMouseX); |
375 |
|
else |
376 |
|
value = valueForYPosition(currentMouseY); |
377 |
|
if (shouldScroll(POSITIVE_SCROLL)) |
378 |
|
scrollByBlock(POSITIVE_SCROLL); |
379 |
|
else if (shouldScroll(NEGATIVE_SCROLL)) |
380 |
|
scrollByBlock(NEGATIVE_SCROLL); |
381 |
|
|
382 |
|
trackHighlight = NO_HIGHLIGHT; |
383 |
|
scrollListener.setScrollByBlock(false); |
384 |
|
scrollbar.setValueIsAdjusting(true); |
385 |
scrollbar.repaint(); |
scrollbar.repaint(); |
386 |
} |
} |
387 |
|
|
401 |
else |
else |
402 |
value = valueForYPosition(currentMouseY); |
value = valueForYPosition(currentMouseY); |
403 |
|
|
404 |
|
if (thumbRect.contains(currentMouseX, currentMouseY)) |
405 |
|
return false; |
406 |
|
|
407 |
if (direction == POSITIVE_SCROLL) |
if (direction == POSITIVE_SCROLL) |
408 |
return (value > scrollbar.getValue()); |
return (value > scrollbar.getValue()); |
409 |
else |
else |
896 |
trackRect = new Rectangle(); |
trackRect = new Rectangle(); |
897 |
thumbRect = new Rectangle(); |
thumbRect = new Rectangle(); |
898 |
|
|
899 |
scrollTimer = new Timer(50, null); |
scrollTimer = new Timer(300, null); |
|
scrollTimer.setRepeats(true); |
|
900 |
|
|
901 |
installComponents(); |
installComponents(); |
902 |
installDefaults(); |
installDefaults(); |