/[classpath]/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicScrollBarUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by langel, Tue Sep 6 15:06:40 2005 UTC revision 1.25 by langel, Fri Sep 23 15:04:53 2005 UTC
# Line 80  public class BasicScrollBarUI extends Sc Line 80  public class BasicScrollBarUI extends Sc
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.
# Line 91  public class BasicScrollBarUI extends Sc Line 92  public class BasicScrollBarUI extends Sc
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    
# Line 105  public class BasicScrollBarUI extends Sc Line 107  public class BasicScrollBarUI extends Sc
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    
# Line 242  public class BasicScrollBarUI extends Sc Line 249  public class BasicScrollBarUI extends Sc
249                scrollbar.repaint();                scrollbar.repaint();
250                return;                return;
251              }              }
252            scrollByBlock(direction);              scrollByBlock(direction);
253          }          }
254        else        else
255          scrollByUnit(direction);          scrollByUnit(direction);
# Line 316  public class BasicScrollBarUI extends Sc Line 323  public class BasicScrollBarUI extends Sc
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();
# Line 333  public class BasicScrollBarUI extends Sc Line 337  public class BasicScrollBarUI extends Sc
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
# Line 343  public class BasicScrollBarUI extends Sc Line 348  public class BasicScrollBarUI extends Sc
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      }      }
# Line 357  public class BasicScrollBarUI extends Sc Line 364  public class BasicScrollBarUI extends Sc
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    
# Line 381  public class BasicScrollBarUI extends Sc Line 401  public class BasicScrollBarUI extends Sc
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
# Line 873  public class BasicScrollBarUI extends Sc Line 896  public class BasicScrollBarUI extends Sc
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();

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26