jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
changeset 38985 2c576be3968c
parent 32865 f9cb6e427f9e
equal deleted inserted replaced
38984:bbded3eab454 38985:2c576be3968c
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1210 
  1210 
  1211             Rectangle r = getTrackBounds();
  1211             Rectangle r = getTrackBounds();
  1212             scrollbar.repaint(r.x, r.y, r.width, r.height);
  1212             scrollbar.repaint(r.x, r.y, r.width, r.height);
  1213 
  1213 
  1214             trackHighlight = NO_HIGHLIGHT;
  1214             trackHighlight = NO_HIGHLIGHT;
  1215             isDragging = false;
  1215             setDragging(false);
  1216             offset = 0;
  1216             offset = 0;
  1217             scrollTimer.stop();
  1217             scrollTimer.stop();
  1218             useCachedValue = true;
  1218             useCachedValue = true;
  1219             scrollbar.setValueIsAdjusting(false);
  1219             scrollbar.setValueIsAdjusting(false);
  1220         }
  1220         }
  1254                     break;
  1254                     break;
  1255                 case JScrollBar.HORIZONTAL:
  1255                 case JScrollBar.HORIZONTAL:
  1256                     offset = currentMouseX - getThumbBounds().x;
  1256                     offset = currentMouseX - getThumbBounds().x;
  1257                     break;
  1257                     break;
  1258                 }
  1258                 }
  1259                 isDragging = true;
  1259                 setDragging(true);
  1260                 return;
  1260                 return;
  1261             }
  1261             }
  1262             else if (getSupportsAbsolutePositioning() &&
  1262             else if (getSupportsAbsolutePositioning() &&
  1263                      SwingUtilities.isMiddleMouseButton(e)) {
  1263                      SwingUtilities.isMiddleMouseButton(e)) {
  1264                 switch (scrollbar.getOrientation()) {
  1264                 switch (scrollbar.getOrientation()) {
  1267                     break;
  1267                     break;
  1268                 case JScrollBar.HORIZONTAL:
  1268                 case JScrollBar.HORIZONTAL:
  1269                     offset = getThumbBounds().width / 2;
  1269                     offset = getThumbBounds().width / 2;
  1270                     break;
  1270                     break;
  1271                 }
  1271                 }
  1272                 isDragging = true;
  1272                 setDragging(true);
  1273                 setValueFrom(e);
  1273                 setValueFrom(e);
  1274                 return;
  1274                 return;
  1275             }
  1275             }
  1276             isDragging = false;
  1276             setDragging(false);
  1277 
  1277 
  1278             Dimension sbSize = scrollbar.getSize();
  1278             Dimension sbSize = scrollbar.getSize();
  1279             direction = +1;
  1279             direction = +1;
  1280 
  1280 
  1281             switch (scrollbar.getOrientation()) {
  1281             switch (scrollbar.getOrientation()) {
  1634                         orient == HORIZONTAL ? EAST : NORTH);
  1634                         orient == HORIZONTAL ? EAST : NORTH);
  1635             }
  1635             }
  1636         }
  1636         }
  1637     }
  1637     }
  1638 
  1638 
       
  1639     private void setDragging(boolean dragging) {
       
  1640         this.isDragging = dragging;
       
  1641         scrollbar.repaint(getThumbBounds());
       
  1642     }
       
  1643 
       
  1644 
  1639     /** Property change handler */
  1645     /** Property change handler */
  1640     public class PropertyChangeHandler implements PropertyChangeListener
  1646     public class PropertyChangeHandler implements PropertyChangeListener
  1641     {
  1647     {
  1642         // NOTE: This class exists only for backward compatibility. All
  1648         // NOTE: This class exists only for backward compatibility. All
  1643         // its functionality has been moved into Handler. If you need to add
  1649         // its functionality has been moved into Handler. If you need to add