OSDN Git Service

2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / plaf / basic / BasicScrollBarUI.java
index 913b326..446726e 100644 (file)
@@ -1,4 +1,4 @@
-/* BasicScrollBarUI.java
+/* BasicScrollBarUI.java --
    Copyright (C) 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package javax.swing.plaf.basic;
 
 import java.awt.Color;
@@ -56,7 +57,6 @@ import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
 import javax.swing.BoundedRangeModel;
-import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JScrollBar;
@@ -70,7 +70,6 @@ import javax.swing.event.ChangeListener;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.ScrollBarUI;
 
-
 /**
  * The Basic Look and Feel UI delegate for JScrollBar.
  */
@@ -78,15 +77,14 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
                                                              SwingConstants
 {
   /**
-   * A helper class that listens to the two JButtons on each end
-   * of the JScrollBar.
+   * A helper class that listens to the two JButtons on each end of the
+   * JScrollBar.
    */
   protected class ArrowButtonListener extends MouseAdapter
   {
     /**
-     * Move the thumb in the direction specified by the 
-     * button's arrow. If this button is held down, then
-     * it should keep moving the thumb.
+     * Move the thumb in the direction specified by the  button's arrow. If
+     * this button is held down, then it should keep moving the thumb.
      *
      * @param e The MouseEvent fired by the JButton.
      */
@@ -113,8 +111,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * A helper class that listens to the ScrollBar's model
-   * for ChangeEvents.
+   * A helper class that listens to the ScrollBar's model for ChangeEvents.
    */
   protected class ModelListener implements ChangeListener
   {
@@ -127,7 +124,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     {
       //       System.err.println(this + ".stateChanged()");
       calculatePreferredSize();
-      layoutContainer(scrollbar);                
+      layoutContainer(scrollbar);
       getThumbBounds();
       scrollbar.repaint();
     }
@@ -157,19 +154,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
          decrButton.removeMouseListener(buttonListener);
          incrButton = createIncreaseButton(scrollbar.getOrientation());
          decrButton = createDecreaseButton(scrollbar.getOrientation());
-          incrButton.addMouseListener(buttonListener);
-          decrButton.addMouseListener(buttonListener);   
-          calculatePreferredSize();
-          layoutContainer(scrollbar);            
-       }
+         incrButton.addMouseListener(buttonListener);
+         decrButton.addMouseListener(buttonListener);
+         calculatePreferredSize();
+         layoutContainer(scrollbar);
+        }
       layoutContainer(scrollbar);
       scrollbar.repaint();
     }
   }
 
   /**
-   * A helper class that listens for events from
-   * the timer that is used to move the thumb.
+   * A helper class that listens for events from the timer that is used to
+   * move the thumb.
    */
   protected class ScrollListener implements ActionListener
   {
@@ -180,8 +177,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     private transient boolean block;
 
     /**
-     * Creates a new ScrollListener object.
-     * The default is scrolling positively with block movement.
+     * Creates a new ScrollListener object. The default is scrolling
+     * positively with block movement.
      */
     public ScrollListener()
     {
@@ -190,8 +187,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     }
 
     /**
-     * Creates a new ScrollListener object using
-     * the given direction and block.
+     * Creates a new ScrollListener object using the given direction and
+     * block.
      *
      * @param dir The direction to move in.
      * @param block Whether movement will be in blocks.
@@ -234,8 +231,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
          // Only need to check it if it's block scrolling
          // We only block scroll if the click occurs
          // in the track.
-         
-         if (!trackListener.shouldScroll(direction))
+         if (! trackListener.shouldScroll(direction))
            {
              trackHighlight = NO_HIGHLIGHT;
              scrollbar.repaint();
@@ -260,13 +256,14 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     /** The current Y coordinate of the mouse. */
     protected int currentMouseY;
 
-    /** The offset between the current mouse cursor and the 
-        current value of the scrollbar. */
+    /**
+     * The offset between the current mouse cursor and the  current value of
+     * the scrollbar.
+     */
     protected int offset;
 
     /**
-     * This method is called when the mouse is being
-     * dragged.
+     * This method is called when the mouse is being dragged.
      *
      * @param e The MouseEvent given.
      */
@@ -275,15 +272,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
       currentMouseX = e.getX();
       currentMouseY = e.getY();
       if (scrollbar.getValueIsAdjusting())
-      {
-        int value;
-        if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
-         value = valueForXPosition(currentMouseX) - offset;
-       else
-         value = valueForYPosition(currentMouseY) - offset;
-       
-       scrollbar.setValue(value);
-      }
+        {
+         int value;
+         if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
+           value = valueForXPosition(currentMouseX) - offset;
+         else
+           value = valueForYPosition(currentMouseY) - offset;
+
+         scrollbar.setValue(value);
+        }
     }
 
     /**
@@ -298,9 +295,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     }
 
     /**
-     * This method is called when the mouse is
-     * pressed. When it is pressed, the thumb should
-     * move in blocks towards the cursor.
+     * This method is called when the mouse is pressed. When it is pressed,
+     * the thumb should move in blocks towards the cursor.
      *
      * @param e The MouseEvent given.
      */
@@ -318,7 +314,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
       if (value == scrollbar.getValue())
        return;
 
-      if (!thumbRect.contains(e.getPoint()))
+      if (! thumbRect.contains(e.getPoint()))
         {
          scrollTimer.stop();
          scrollListener.setScrollByBlock(true);
@@ -344,13 +340,13 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
          // to that value.
          scrollbar.setValueIsAdjusting(true);
          offset = value - scrollbar.getValue();
-       }
-      scrollbar.repaint();      
+        }
+      scrollbar.repaint();
     }
 
     /**
-     * This method is called when the mouse is released.
-     * It should stop movement on the thumb
+     * This method is called when the mouse is released. It should stop
+     * movement on the thumb
      *
      * @param e The MouseEvent given.
      */
@@ -358,32 +354,32 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     {
       trackHighlight = NO_HIGHLIGHT;
       scrollTimer.stop();
-      
+
       if (scrollbar.getValueIsAdjusting())
-        scrollbar.setValueIsAdjusting(false);
+       scrollbar.setValueIsAdjusting(false);
       scrollbar.repaint();
     }
-    
+
     /**
-     * A helper method that decides whether we should
-     * keep scrolling in the given direction.
+     * A helper method that decides whether we should keep scrolling in the
+     * given direction.
      *
      * @param direction The direction to check for.
      *
      * @return Whether the thumb should keep scrolling.
      */
-    public boolean shouldScroll (int direction)
+    public boolean shouldScroll(int direction)
     {
       int value;
       if (scrollbar.getOrientation() == HORIZONTAL)
-        value = valueForXPosition(currentMouseX);
+       value = valueForXPosition(currentMouseX);
       else
-        value = valueForYPosition(currentMouseY);
+       value = valueForYPosition(currentMouseY);
 
       if (direction == POSITIVE_SCROLL)
-        return (value > scrollbar.getValue());
+       return (value > scrollbar.getValue());
       else
-        return (value < scrollbar.getValue());
+       return (value < scrollbar.getValue());
     }
   }
 
@@ -393,8 +389,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   /** The listener that listens to the model. */
   protected ModelListener modelListener;
 
-  /** The listener that listens to the scrollbar for property
-      changes. */
+  /** The listener that listens to the scrollbar for property changes. */
   protected PropertyChangeListener propertyChangeListener;
 
   /** The listener that listens to the timer. */
@@ -410,10 +405,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   protected JButton incrButton;
 
   /** The dimensions of the maximum thumb size. */
-  protected static Dimension maximumThumbSize;
+  protected Dimension maximumThumbSize;
 
   /** The dimensions of the minimum thumb size. */
-  protected static Dimension minimumThumbSize;
+  protected Dimension minimumThumbSize;
 
   /** The color of the thumb. */
   protected Color thumbColor;
@@ -427,8 +422,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   /** The outer light shadow for the thumb. */
   protected Color thumbLightShadowColor;
 
-  /** The color that is used when the mouse press
-      occurs in the track. */
+  /** The color that is used when the mouse press occurs in the track. */
   protected Color trackHighlightColor;
 
   /** The color of the track. */
@@ -441,19 +435,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   protected Rectangle thumbRect;
 
   /** Indicates that the decrease highlight should be painted. */
-  protected static int DECREASE_HIGHLIGHT = 1;
+  protected static final int DECREASE_HIGHLIGHT = 1;
 
   /** Indicates that the increase highlight should be painted. */
-  protected static int INCREASE_HIGHLIGHT = 2;
+  protected static final int INCREASE_HIGHLIGHT = 2;
 
   /** Indicates that no highlight should be painted. */
-  protected static int NO_HIGHLIGHT = 0;
+  protected static final int NO_HIGHLIGHT = 0;
 
   /** Indicates that the scrolling direction is positive. */
-  private static int POSITIVE_SCROLL = 1;
+  private static final int POSITIVE_SCROLL = 1;
 
   /** Indicates that the scrolling direction is negative. */
-  private static int NEGATIVE_SCROLL = -1;
+  private static final int NEGATIVE_SCROLL = -1;
 
   /** The cached preferred size for the scrollbar. */
   private transient Dimension preferredSize;
@@ -471,88 +465,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   protected JScrollBar scrollbar;
 
   /**
-   * A helper class that allows us to draw icons for 
-   * the JButton.
-   */
-  private static class arrowIcon implements Icon
-  {
-    /** The polygon that describes the icon. */
-    private Polygon arrow;
-
-    /**
-     * Creates a new arrowIcon object.
-     *
-     * @param arrow The polygon that describes the arrow.
-     */
-    public arrowIcon(Polygon arrow)
-    {
-      this.arrow = arrow;
-    }
-
-    /**
-     * Returns the height of the icon.
-     *
-     * @return The height of the icon.
-     */
-    public int getIconHeight()
-    {
-      return 10;
-    }
-
-    /**
-     * Returns the width of the icon.
-     *
-     * @return The width of the icon.
-     */
-    public int getIconWidth()
-    {
-      return 10;
-    }
-
-    /**
-     * Paints the icon.
-     *
-     * @param c The Component to paint for.
-     * @param g The Graphics object to draw with.
-     * @param x The X coordinate to draw at.
-     * @param y The Y coordinate to draw at.
-     */
-    public void paintIcon(Component c, Graphics g, int x, int y)
-    {
-      g.translate(x, y);
-
-      Color saved = g.getColor();
-
-      g.setColor(Color.BLACK);
-
-      g.fillPolygon(arrow);
-
-      g.setColor(saved);
-      g.translate(-x, -y);
-    }
-  }
-
-  /** The Icon that points up. */
-  private static Icon upIcon = new arrowIcon(new Polygon(new int[] { 2, 5, 8 },
-                                                            new int[] { 7, 3, 7 },
-                                                            3));
-
-  /** The Icon that points down. */
-  private static Icon downIcon = new arrowIcon(new Polygon(new int[] { 2, 5, 8 },
-                                                              new int[] { 3, 7, 3 },
-                                                              3));
-
-  /** The Icon that points left. */
-  private static Icon leftIcon = new arrowIcon(new Polygon(new int[] { 7, 3, 7 },
-                                                              new int[] { 2, 5, 8 },
-                                                              3));
-
-  /** The Icon that points right. */
-  private static Icon rightIcon = new arrowIcon(new Polygon(new int[] { 3, 7, 3},
-                                                            new int[] { 2, 5, 8}, 
-                                                            3));
-
-  /**
    * This method adds a component to the layout.
    *
    * @param name The name to associate with the component that is added.
@@ -565,19 +477,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method configures the scrollbar's colors. This can be 
-   * done by looking up the standard colors from the Look and Feel defaults.
+   * This method configures the scrollbar's colors. This can be  done by
+   * looking up the standard colors from the Look and Feel defaults.
    */
   protected void configureScrollBarColors()
   {
     UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-  
+
     trackColor = defaults.getColor("ScrollBar.track");
     trackHighlightColor = defaults.getColor("ScrollBar.trackHighlight");
     thumbColor = defaults.getColor("ScrollBar.thumb");
     thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
     thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
-    thumbLightShadowColor = defaults.getColor("ScrollBar.thumbLightShadow");  
+    thumbLightShadowColor = defaults.getColor("ScrollBar.thumbLightShadow");
   }
 
   /**
@@ -590,9 +502,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     return new ArrowButtonListener();
   }
 
-  /** 
-   * This method creates a new JButton with the appropriate
-   * icon for the orientation.
+  /**
+   * This method creates a new JButton with the appropriate icon for the
+   * orientation.
    *
    * @param orientation The orientation this JButton uses.
    *
@@ -601,26 +513,22 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   protected JButton createIncreaseButton(int orientation)
   {
     if (incrButton == null)
+      incrButton = new BasicArrowButton((orientation == SwingConstants.HORIZONTAL)
+                                        ? SwingConstants.EAST
+                                        : SwingConstants.SOUTH);
+    else
       {
-      incrButton = new JButton();
-        incrButton.setMargin(new Insets(0,0,0,0));
-        incrButton.setHorizontalAlignment(SwingConstants.CENTER);
-        incrButton.setHorizontalTextPosition(SwingConstants.CENTER);
-        incrButton.setVerticalAlignment(SwingConstants.CENTER);
-        incrButton.setVerticalTextPosition(SwingConstants.CENTER);
+       if (orientation == SwingConstants.HORIZONTAL)
+         ((BasicArrowButton) incrButton).setDirection(SwingConstants.EAST);
+       else
+         ((BasicArrowButton) incrButton).setDirection(SwingConstants.SOUTH);
       }
-    
-    if (orientation == SwingConstants.HORIZONTAL)
-      incrButton.setIcon(rightIcon);
-    else
-      incrButton.setIcon(downIcon);
-
     return incrButton;
   }
 
   /**
-   * This method creates a new JButton with the appropriate
-   * icon for the orientation.
+   * This method creates a new JButton with the appropriate icon for the
+   * orientation.
    *
    * @param orientation The orientation this JButton uses.
    *
@@ -629,20 +537,16 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   protected JButton createDecreaseButton(int orientation)
   {
     if (decrButton == null)
+      decrButton = new BasicArrowButton((orientation == SwingConstants.HORIZONTAL)
+                                        ? SwingConstants.WEST
+                                        : SwingConstants.NORTH);
+    else
       {
-      decrButton = new JButton();
-        decrButton.setMargin(new Insets(0,0,0,0));
-        decrButton.setHorizontalAlignment(SwingConstants.CENTER);
-        decrButton.setHorizontalTextPosition(SwingConstants.CENTER);
-        decrButton.setVerticalAlignment(SwingConstants.CENTER);
-        decrButton.setVerticalTextPosition(SwingConstants.CENTER);
+       if (orientation == SwingConstants.HORIZONTAL)
+         ((BasicArrowButton) decrButton).setDirection(SwingConstants.WEST);
+       else
+         ((BasicArrowButton) decrButton).setDirection(SwingConstants.NORTH);
       }
-
-    if (orientation == SwingConstants.HORIZONTAL)
-      decrButton.setIcon(leftIcon);
-    else
-      decrButton.setIcon(upIcon);
-
     return decrButton;
   }
 
@@ -743,13 +647,12 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method calculates the preferred size since
-   * calling getPreferredSize() returns a cached value.
+   * This method calculates the preferred size since calling
+   * getPreferredSize() returns a cached value.
    */
   private void calculatePreferredSize()
   {
     // System.err.println(this + ".calculatePreferredSize()");
-
     int height;
     int width;
     height = width = 0;
@@ -790,11 +693,11 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method returns a cached value of the preferredSize.
-   * The only restrictions are: If the scrollbar is horizontal, the
-   * height should be the maximum of the height of the JButtons and 
-   * the minimum width of the thumb. For vertical scrollbars, the 
-   * calculation is similar (swap width for height and vice versa).
+   * This method returns a cached value of the preferredSize. The only
+   * restrictions are: If the scrollbar is horizontal, the height should be
+   * the maximum of the height of the JButtons and  the minimum width of the
+   * thumb. For vertical scrollbars, the  calculation is similar (swap width
+   * for height and vice versa).
    *
    * @param c The JComponent to measure.
    *
@@ -807,9 +710,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method returns the thumb's bounds based on the 
-   * current value of the scrollbar. This method updates the
-   * cached value and returns that.
+   * This method returns the thumb's bounds based on the  current value of the
+   * scrollbar. This method updates the cached value and returns that.
    *
    * @return The thumb bounds.
    */
@@ -821,24 +723,22 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     int extent = scrollbar.getVisibleAmount();
 
     // System.err.println(this + ".getThumbBounds()");
-
     if (max == min)
-    {
-      thumbRect.x = trackRect.x;
-      thumbRect.y = trackRect.y;
-      if (scrollbar.getOrientation() == HORIZONTAL)
       {
-       thumbRect.width = getMinimumThumbSize().width;
-       thumbRect.height = trackRect.height;
-      }
-      else
-      {
-        thumbRect.width = trackRect.width;
-       thumbRect.height = getMinimumThumbSize().height;
+       thumbRect.x = trackRect.x;
+       thumbRect.y = trackRect.y;
+       if (scrollbar.getOrientation() == HORIZONTAL)
+         {
+           thumbRect.width = getMinimumThumbSize().width;
+           thumbRect.height = trackRect.height;
+         }
+       else
+         {
+           thumbRect.width = trackRect.width;
+           thumbRect.height = getMinimumThumbSize().height;
+         }
+       return thumbRect;
       }
-      return thumbRect;
-    }
-               
 
     if (scrollbar.getOrientation() == HORIZONTAL)
       {
@@ -852,8 +752,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     else
       {
        thumbRect.x = trackRect.x;
-       thumbRect.y = trackRect.y
-                     + value * trackRect.height / (max - min);
+       thumbRect.y = trackRect.y + value * trackRect.height / (max - min);
 
        thumbRect.width = trackRect.width;
        thumbRect.height = extent * trackRect.height / (max - min);
@@ -862,8 +761,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method calculates the bounds of the track. This method
-   * updates the cached value and returns it.
+   * This method calculates the bounds of the track. This method updates the
+   * cached value and returns it.
    *
    * @return The track's bounds.
    */
@@ -889,8 +788,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method installs any addition Components that 
-   * are a part of or related to this scrollbar.
+   * This method installs any addition Components that  are a part of or
+   * related to this scrollbar.
    */
   protected void installComponents()
   {
@@ -901,8 +800,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method installs the defaults for the scrollbar specified
-   * by the Basic Look and Feel.
+   * This method installs the defaults for the scrollbar specified by the
+   * Basic Look and Feel.
    */
   protected void installDefaults()
   {
@@ -926,9 +825,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method installs any listeners for the scrollbar.
-   * This method also installs listeners for things such as
-   * the JButtons and the timer.
+   * This method installs any listeners for the scrollbar. This method also
+   * installs listeners for things such as the JButtons and the timer.
    */
   protected void installListeners()
   {
@@ -951,10 +849,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method installs the UI for the component.
-   * This can include setting up listeners, defaults, 
-   * and components. This also includes initializing any data
-   * objects.
+   * This method installs the UI for the component. This can include setting
+   * up listeners, defaults,  and components. This also includes initializing
+   * any data objects.
    *
    * @param c The JComponent to install.
    */
@@ -977,7 +874,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
        configureScrollBarColors();
 
        calculatePreferredSize();
-        layoutContainer(scrollbar);    
+       layoutContainer(scrollbar);
       }
   }
 
@@ -1073,9 +970,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method is called when repainting and the mouse is 
-   * pressed in the track. It paints the track below the thumb
-   * with the trackHighlight color.
+   * This method is called when repainting and the mouse is  pressed in the
+   * track. It paints the track below the thumb with the trackHighlight
+   * color.
    *
    * @param g The Graphics object to paint with.
    */
@@ -1088,15 +985,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
       g.fillRect(trackRect.x, trackRect.y, thumbRect.x - trackRect.x,
                  trackRect.height);
     else
-      g.fillRect(trackRect.x, trackRect.y, trackRect.width, 
+      g.fillRect(trackRect.x, trackRect.y, trackRect.width,
                  thumbRect.y - trackRect.y);
     g.setColor(saved);
   }
 
   /**
-   * This method is called when repainting and the mouse is 
-   * pressed in the track. It paints the track above the thumb
-   * with the trackHighlight color.
+   * This method is called when repainting and the mouse is  pressed in the
+   * track. It paints the track above the thumb with the trackHighlight
+   * color.
    *
    * @param g The Graphics objet to paint with.
    */
@@ -1109,11 +1006,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
       g.fillRect(thumbRect.x + thumbRect.width, trackRect.y,
                  trackRect.x + trackRect.width - thumbRect.x - thumbRect.width,
                  trackRect.height);
-    else   
-      g.fillRect(trackRect.x, thumbRect.y + thumbRect.height, 
-                 trackRect.width,
-                 trackRect.y + trackRect.height - thumbRect.y - 
-                thumbRect.height);
+    else
+      g.fillRect(trackRect.x, thumbRect.y + thumbRect.height, trackRect.width,
+                 trackRect.y + trackRect.height - thumbRect.y
+                 - thumbRect.height);
     g.setColor(saved);
   }
 
@@ -1217,25 +1113,25 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * The method scrolls the thumb by a block in the 
-   * direction specified.
+   * The method scrolls the thumb by a block in the  direction specified.
    *
    * @param direction The direction to scroll.
    */
   protected void scrollByBlock(int direction)
   {
-    scrollbar.setValue(scrollbar.getValue() + scrollbar.getBlockIncrement(direction));
+    scrollbar.setValue(scrollbar.getValue()
+                       + scrollbar.getBlockIncrement(direction));
   }
 
   /**
-   * The method scrolls the thumb by a unit in the
-   * direction specified.
+   * The method scrolls the thumb by a unit in the direction specified.
    *
    * @param direction The direction to scroll.
    */
   protected void scrollByUnit(int direction)
   {
-    scrollbar.setValue(scrollbar.getValue() + scrollbar.getUnitIncrement(direction));
+    scrollbar.setValue(scrollbar.getValue()
+                       + scrollbar.getUnitIncrement(direction));
   }
 
   /**
@@ -1255,8 +1151,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method uninstalls any components that 
-   * are a part of or related to this scrollbar.
+   * This method uninstalls any components that  are a part of or related to
+   * this scrollbar.
    */
   protected void uninstallComponents()
   {
@@ -1267,8 +1163,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method uninstalls any defaults that this
-   * scrollbar acquired from the Basic Look and Feel defaults.
+   * This method uninstalls any defaults that this scrollbar acquired from the
+   * Basic Look and Feel defaults.
    */
   protected void uninstallDefaults()
   {
@@ -1278,8 +1174,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method uninstalls any keyboard
-   * actions this scrollbar acquired during install.
+   * This method uninstalls any keyboard actions this scrollbar acquired
+   * during install.
    */
   protected void uninstallKeyboardActions()
   {
@@ -1287,22 +1183,21 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method uninstalls any listeners that
-   * were registered during install.
+   * This method uninstalls any listeners that were registered during install.
    */
   protected void uninstallListeners()
   {
     scrollTimer.removeActionListener(scrollListener);
-    
+
     scrollbar.getModel().removeChangeListener(modelListener);
     scrollbar.removePropertyChangeListener(propertyChangeListener);
-    
+
     decrButton.removeMouseListener(buttonListener);
     incrButton.removeMouseListener(buttonListener);
-    
+
     scrollbar.removeMouseListener(trackListener);
     scrollbar.removeMouseMotionListener(trackListener);
-    
+
     propertyChangeListener = null;
     modelListener = null;
     buttonListener = null;
@@ -1311,10 +1206,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
   }
 
   /**
-   * This method uninstalls the UI. This includes
-   * removing any defaults, listeners, and components
-   * that this UI may have initialized. It also nulls
-   * any instance data.
+   * This method uninstalls the UI. This includes removing any defaults,
+   * listeners, and components that this UI may have initialized. It also
+   * nulls any instance data.
    *
    * @param c The Component to uninstall for.
    */
@@ -1323,19 +1217,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     uninstallDefaults();
     uninstallListeners();
     uninstallComponents();
-    
+
     scrollTimer = null;
-    
+
     thumbRect = null;
     trackRect = null;
-    
+
     trackColor = null;
     trackHighlightColor = null;
     thumbColor = null;
     thumbHighlightColor = null;
     thumbDarkShadowColor = null;
     thumbLightShadowColor = null;
-    
+
     scrollbar = null;
   }