src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


 256     /**
 257      * {@inheritDoc}
 258      * @since 1.6
 259      */
 260     @Override
 261     protected void setThumbRollover(boolean active) {
 262         boolean old = isThumbRollover();
 263         super.setThumbRollover(active);
 264         // we need to repaint the entire scrollbar because state change for thumb
 265         // causes state change for incr and decr buttons on Vista
 266         if(XPStyle.isVista() && active != old) {
 267             scrollbar.repaint();
 268         }
 269     }
 270 
 271     /**
 272      * WindowsArrowButton is used for the buttons to position the
 273      * document up/down. It differs from BasicArrowButton in that the
 274      * preferred size is always a square.
 275      */

 276     private class WindowsArrowButton extends BasicArrowButton {
 277 
 278         public WindowsArrowButton(int direction, Color background, Color shadow,
 279                          Color darkShadow, Color highlight) {
 280             super(direction, background, shadow, darkShadow, highlight);
 281         }
 282 
 283         public WindowsArrowButton(int direction) {
 284             super(direction);
 285         }
 286 
 287         public void paint(Graphics g) {
 288             XPStyle xp = XPStyle.getXP();
 289             if (xp != null) {
 290                 ButtonModel model = getModel();
 291                 Skin skin = xp.getSkin(this, Part.SBP_ARROWBTN);
 292                 State state = null;
 293 
 294                 boolean jointRollover = XPStyle.isVista() && (isThumbRollover() ||
 295                     (this == incrButton && decrButton.getModel().isRollover()) ||


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  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  *
  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


 256     /**
 257      * {@inheritDoc}
 258      * @since 1.6
 259      */
 260     @Override
 261     protected void setThumbRollover(boolean active) {
 262         boolean old = isThumbRollover();
 263         super.setThumbRollover(active);
 264         // we need to repaint the entire scrollbar because state change for thumb
 265         // causes state change for incr and decr buttons on Vista
 266         if(XPStyle.isVista() && active != old) {
 267             scrollbar.repaint();
 268         }
 269     }
 270 
 271     /**
 272      * WindowsArrowButton is used for the buttons to position the
 273      * document up/down. It differs from BasicArrowButton in that the
 274      * preferred size is always a square.
 275      */
 276     @SuppressWarnings("serial") // Superclass is not serializable across versions
 277     private class WindowsArrowButton extends BasicArrowButton {
 278 
 279         public WindowsArrowButton(int direction, Color background, Color shadow,
 280                          Color darkShadow, Color highlight) {
 281             super(direction, background, shadow, darkShadow, highlight);
 282         }
 283 
 284         public WindowsArrowButton(int direction) {
 285             super(direction);
 286         }
 287 
 288         public void paint(Graphics g) {
 289             XPStyle xp = XPStyle.getXP();
 290             if (xp != null) {
 291                 ButtonModel model = getModel();
 292                 Skin skin = xp.getSkin(this, Part.SBP_ARROWBTN);
 293                 State state = null;
 294 
 295                 boolean jointRollover = XPStyle.isVista() && (isThumbRollover() ||
 296                     (this == incrButton && decrButton.getModel().isRollover()) ||