This finishes up the SplitPane UI work:
- Removed debug output.
- Refactored BasicSplitPaneUI layout managers to conform with the spec. The BasicVerticalLayoutManager has no impl as of JDK5 and the functionality seems to be moved to BasicHorizontalLayoutManager. - Fine-tuned the MetalSplitPaneDivider buttons and pattern painting to be more like the JDK.

2006-08-14  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicSplitPaneDivider.java
        (DividerLayout.layoutContainer): Removed debug output.
        * javax/swing/plaf/basic/BasicSplitPaneUI.java
        (BasicHorizontalLayoutManager.axis): New field.
        (BasicHorizontalLayoutManager.BasicHorizontalLayoutManager(int)):
        New constructor.
        (BasicHorizontalLayoutManager.BasicHorizontalLayoutManager()):
        Call new axis constructor.
        (BasicHorizontalLayoutManager.getAvailableSize): Refactored to
        handle direction.
        (BasicHorizontalLayoutManager.getInitialLocation): Refactored to
        handle direction.
        (BasicHorizontalLayoutManager.getPreferredSizeOfComponent):
        Refactored to handle direction.
        (BasicHorizontalLayoutManager.getSizeOfComponent): Refactored
        to handle direction.
        (BasicHorizontalLayoutManager.minimumLayoutSize): Refactored to
        handle direction.
        (BasicHorizontalLayoutManager.preferredLayoutSize): Refactored
        to handle direction.
        (BasicHorizontalLayoutManager.minimumSizeOfComponent): Refactored
        to handle direction.
        (BasicHorizontalLayoutManager.setComponentToSize): Refactored
        to handle direction.
        (BasicHorizontalLayoutManager.updateComponents): Don't reset
        divider size.
        (BasicVerticalLayoutManager.BasicVerticalLayoutManager):
        New explicit constructor. Calls super with vertical axis.
        (BasicVerticalLayoutManager.getAvailableSize): Functionality moved
        to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.getInitialLocation): Functionality
        moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.getPreferredSizeOfComponent):
        Functionality moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.getSizeOfComponent): Functionality
        moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.minimumLayoutSize): Functionality
        moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.minimumSizeOfComponent):
        Functionality moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.preferredLayoutSize): Functionality
        moved to BasicHorizontalLayoutManager.
        (BasicVerticalLayoutManager.setComponentToSize): Functionality
        moved to BasicHorizontalLayoutManager.
        * javax/swing/plaf/metal/MetalSplitPaneDivider.java
        (BUTTON_SPRITE): Renamed to BUTTON_SPRITE_L.
        (BUTTON_SPRITE_R): New constant field.
        (MetalOneTouchButton.paint): Paint R sprite for right buttons,
        L sprite for left buttons.

/Roman
Index: javax/swing/plaf/basic/BasicSplitPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,v
retrieving revision 1.31
diff -u -1 -2 -r1.31 BasicSplitPaneUI.java
--- javax/swing/plaf/basic/BasicSplitPaneUI.java	14 Aug 2006 13:40:01 -0000	1.31
+++ javax/swing/plaf/basic/BasicSplitPaneUI.java	14 Aug 2006 21:39:37 -0000
@@ -54,24 +54,25 @@
 import java.awt.event.FocusListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
 import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
 import javax.swing.InputMap;
 import javax.swing.JComponent;
 import javax.swing.JSlider;
 import javax.swing.JSplitPane;
 import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
+import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.SplitPaneUI;
 import javax.swing.plaf.UIResource;
 
 /**
  * This is the Basic Look and Feel implementation of the SplitPaneUI  class.
  */
 public class BasicSplitPaneUI extends SplitPaneUI
 {
@@ -98,31 +99,52 @@
     protected Component[] components = new Component[3];
 
     // These are the _current_ widths of the associated component.
 
     /**
      * This array contains the current width (for HORIZONTAL_SPLIT) or height
      * (for VERTICAL_SPLIT) of the components. The indices are the same as
      * for components.
      */
     protected int[] sizes = new int[3];
 
     /**
+     * This is used to determine if we are vertical or horizontal layout.
+     * In the JDK, the BasicVerticalLayoutManager seems to have no more
+     * methods implemented (as of JDK5), so we keep this state here.
+     */
+    private int axis;
+
+    /**
      * Creates a new instance. This is package private because the reference
      * implementation has no public constructor either. Still, we need to
      * call it from BasicVerticalLayoutManager.
      */
     BasicHorizontalLayoutManager()
     {
-      // Nothing to do here.
+      this(SwingConstants.HORIZONTAL);
+    }
+
+    /**
+     * Creates a new instance for a specified axis. This is provided for
+     * compatibility, since the BasicVerticalLayoutManager seems to have
+     * no more implementation in the RI, according to the specs. So
+     * we handle all the axis specific stuff here.
+     *
+     * @param a the axis, either SwingConstants#HORIZONTAL,
+     *        or SwingConstants#VERTICAL
+     */
+    BasicHorizontalLayoutManager(int a)
+    {
+      axis = a;
     }
 
     /**
      * This method adds the component given to the JSplitPane. The position of
      * the component is given by the constraints object.
      *
      * @param comp The Component to add.
      * @param constraints The constraints that bind the object.
      */
     public void addLayoutComponent(Component comp, Object constraints)
     {
       addLayoutComponent((String) constraints, comp);
@@ -158,40 +180,51 @@
     }
 
     /**
      * This method returns the width of the JSplitPane minus the insets.
      *
      * @param containerSize The Dimensions of the JSplitPane.
      * @param insets The Insets of the JSplitPane.
      *
      * @return The width of the JSplitPane minus the insets.
      */
     protected int getAvailableSize(Dimension containerSize, Insets insets)
     {
-      return containerSize.width - insets.left - insets.right;
+      int size;
+      if (axis == SwingConstants.HORIZONTAL)
+        size = containerSize.width - insets.left - insets.right;
+      else
+        size = containerSize.height - insets.top - insets.bottom;
+      return size;
     }
 
     /**
      * This method returns the given insets left value. If the  given inset is
      * null, then 0 is returned.
      *
      * @param insets The Insets to use with the JSplitPane.
      *
      * @return The inset's left value.
      */
     protected int getInitialLocation(Insets insets)
     {
+      int loc = 0;
       if (insets != null)
-        return insets.left;
-      return 0;
+        {
+          if (axis == SwingConstants.HORIZONTAL)
+            loc = insets.left;
+          else
+            loc = insets.top;
+        }
+      return loc;
     }
 
     /**
      * This specifies how a component is aligned with respect to  other
      * components in the x fdirection.
      *
      * @param target The container.
      *
      * @return The component's alignment.
      */
     public float getLayoutAlignmentX(Container target)
     {
@@ -211,40 +244,54 @@
       return target.getAlignmentY();
     }
 
     /**
      * This method returns the preferred width of the component.
      *
      * @param c The component to measure.
      *
      * @return The preferred width of the component.
      */
     protected int getPreferredSizeOfComponent(Component c)
     {
+      int size = 0;
       Dimension dims = c.getPreferredSize();
-      if (dims != null)
-        return dims.width;
-      return 0;
+      if (axis == SwingConstants.HORIZONTAL)
+        {
+          if (dims != null)
+            size = dims.width;
+        }
+      else
+        {
+          if (dims != null)
+            size = dims.height;
+        }
+      return size;
     }
 
     /**
      * This method returns the current width of the component.
      *
      * @param c The component to measure.
      *
      * @return The width of the component.
      */
     protected int getSizeOfComponent(Component c)
     {
-      return c.getWidth();
+      int size;
+      if (axis == SwingConstants.HORIZONTAL)
+        size = c.getHeight();
+      else
+        size = c.getWidth();
+      return size;
     }
 
     /**
      * This method returns the sizes array.
      *
      * @return The sizes array.
      */
     protected int[] getSizes()
     {
       return sizes;
     }
 
@@ -304,80 +351,87 @@
 
     /**
      * This method returns the container's minimum size. The  minimum width is
      * the sum of all the component's minimum widths. The minimum height is
      * the maximum of  all the components' minimum heights.
      *
      * @param target The container to measure.
      *
      * @return The minimum size.
      */
     public Dimension minimumLayoutSize(Container target)
     {
+      Dimension dim = new Dimension();
       if (target instanceof JSplitPane)
         {
           JSplitPane split = (JSplitPane) target;
-          Insets insets = target.getInsets();
-
-          int height = 0;
-          int width = 0;
+          int primary = 0;
+          int secondary = 0;
           for (int i = 0; i < components.length; i++)
             {
-              if (components[i] == null)
-                continue;
-              Dimension dims = components[i].getMinimumSize();
-              if (dims != null)
+              if (components[i] != null)
                 {
-                  width += dims.width;
-                  height = Math.max(height, dims.height);
+                  Dimension dims = components[i].getMinimumSize();
+                  primary += axis == SwingConstants.HORIZONTAL ? dims.width
+                                                               : dims.height;
+                  int sec = axis == SwingConstants.HORIZONTAL ? dims.height
+                                                              : dims.width;
+                  secondary = Math.max(sec, secondary);
                 }
             }
-          return new Dimension(width, height);
+          int width = axis == SwingConstants.HORIZONTAL ? primary : secondary;
+          int height = axis == SwingConstants.VERTICAL ? secondary : primary;
+
+          Insets i = splitPane.getInsets();
+          dim.setSize(width + i.left + i.right, height + i.top + i.bottom);
         }
-      return null;
+      return dim;
     }
 
     /**
      * This method returns the container's preferred size. The preferred width
      * is the sum of all the component's preferred widths. The preferred
      * height is the maximum of all the components' preferred heights.
      *
      * @param target The container to measure.
      *
      * @return The preferred size.
      */
     public Dimension preferredLayoutSize(Container target)
     {
+      Dimension dim = new Dimension();
       if (target instanceof JSplitPane)
         {
           JSplitPane split = (JSplitPane) target;
-          Insets insets = target.getInsets();
-
-          int height = 0;
-          int width = 0;
+          int primary = 0;
+          int secondary = 0;
           for (int i = 0; i < components.length; i++)
             {
-              if (components[i] == null)
-                continue;
-              Dimension dims = components[i].getPreferredSize();
-              if (dims != null)
+              if (components[i] != null)
                 {
-                  width += dims.width;
-                  if (!(components[i] instanceof BasicSplitPaneDivider))
-                    height = Math.max(height, dims.height);
+                  Dimension dims = components[i].getPreferredSize();
+                  primary += axis == SwingConstants.HORIZONTAL ? dims.width
+                                                               : dims.height;
+                  int sec = axis == SwingConstants.HORIZONTAL ? dims.height
+                                                              : dims.width;
+                  secondary = Math.max(sec, secondary);
                 }
             }
-          return new Dimension(width, height);
+          int width = axis == SwingConstants.HORIZONTAL ? primary : secondary;
+          int height = axis == SwingConstants.VERTICAL ? secondary : primary;
+
+          Insets i = splitPane.getInsets();
+          dim.setSize(width + i.left + i.right, height + i.top + i.bottom);
         }
-      return null;
+      return dim;
     }
 
     /**
      * This method removes the component from the layout.
      *
      * @param component The component to remove from the layout.
      */
     public void removeLayoutComponent(Component component)
     {
       for (int i = 0; i < components.length; i++)
         {
           if (component == components[i])
@@ -416,29 +470,41 @@
      * inset. The x coordinate is the location given.  The y coordinate is
      * the top inset.
      *
      * @param c The component to set.
      * @param size The width of the component.
      * @param location The x coordinate.
      * @param insets The insets to use.
      * @param containerSize The height of the container.
      */
     protected void setComponentToSize(Component c, int size, int location,
                                       Insets insets, Dimension containerSize)
     { 
-      int w = size;
-      int h = containerSize.height - insets.top - insets.bottom;
-      int x = location;
-      int y = insets.top;
-      c.setBounds(x, y, w, h);
+      if (insets != null)
+        {
+          if (axis == SwingConstants.HORIZONTAL)
+            c.setBounds(location, insets.top, size,
+                        containerSize.height - insets.top - insets.bottom);
+          else
+            c.setBounds(insets.left, location,
+                        containerSize.width - insets.left - insets.right,
+                        size);
+        }
+      else
+        {
+          if (axis == SwingConstants.HORIZONTAL)
+            c.setBounds(location, 0, size, containerSize.height);
+          else
+            c.setBounds(0, location, containerSize.width, size);
+        }
     }
 
     /**
      * This method stores the given int array as the new sizes array.
      *
      * @param newSizes The array to use as sizes.
      */
     protected void setSizes(int[] newSizes)
     {
       sizes = newSizes;
     }
 
@@ -453,223 +519,73 @@
 
       if (left != null)
         {
           components[0] = left;
           resetSizeAt(0);
         }
       if (right != null)
         {
           components[1] = right;
           resetSizeAt(1);
         }
       components[2] = divider;
-      resetSizeAt(2);
     }
 
     /**
      * This method resizes the left and right components to fit inside the
      * JSplitPane when there is extra space.
      */
     void distributeExtraSpace()
     {
       // FIXME: This needs to be reimplemented correctly.
     }
 
     /**
      * This method returns the minimum width of the  component at the given
      * index.
      *
      * @param index The index to check.
      *
      * @return The minimum width.
      */
     int minimumSizeOfComponent(int index)
     {
       Dimension dims = components[index].getMinimumSize();
+      int size = 0;
       if (dims != null)
-        return dims.width;
-      else
-        return 0;
+        if (axis == SwingConstants.HORIZONTAL)
+          size = dims.width;
+        else
+          size = dims.height;
+        return size;
     }
   } //end BasicHorizontalLayoutManager
 
   /**
    * This class is the Layout Manager for the JSplitPane when the orientation
    * is VERTICAL_SPLIT.
    *
    * @specnote Apparently this class was intended to be protected,
    *           but was made public by a compiler bug and is now
    *           public for compatibility.
    */
   public class BasicVerticalLayoutManager
     extends BasicHorizontalLayoutManager
   {
     /**
-     * This method returns the height of the container minus the top and
-     * bottom inset.
-     *
-     * @param containerSize The size of the container.
-     * @param insets The insets of the container.
-     *
-     * @return The height minus top and bottom inset.
-     */
-    protected int getAvailableSize(Dimension containerSize, Insets insets)
-    {
-      return containerSize.height - insets.top - insets.bottom;
-    }
-
-    /**
-     * This method returns the top inset.
-     *
-     * @param insets The Insets to use.
-     *
-     * @return The top inset.
-     */
-    protected int getInitialLocation(Insets insets)
-    {
-      return insets.top;
-    }
-
-    /**
-     * This method returns the preferred height of the component.
-     *
-     * @param c The component to measure.
-     *
-     * @return The preferred height of the component.
+     * Creates a new instance.
      */
-    protected int getPreferredSizeOfComponent(Component c)
+    public BasicVerticalLayoutManager()
     {
-      Dimension dims = c.getPreferredSize();
-      if (dims != null)
-        return dims.height;
-      return 0;
-    }
-
-    /**
-     * This method returns the current height of the component.
-     *
-     * @param c The component to measure.
-     *
-     * @return The current height of the component.
-     */
-    protected int getSizeOfComponent(Component c)
-    {
-      return c.getHeight();
-    }
-
-    /**
-     * This method returns the minimum layout size. The minimum height is the
-     * sum of all the components' minimum heights. The minimum width is the
-     * maximum of all the  components' minimum widths.
-     *
-     * @param container The container to measure.
-     *
-     * @return The minimum size.
-     */
-    public Dimension minimumLayoutSize(Container container)
-    {
-      if (container instanceof JSplitPane)
-        {
-          JSplitPane split = (JSplitPane) container;
-          Insets insets = container.getInsets();
-
-          int height = 0;
-          int width = 0;
-          for (int i = 0; i < components.length; i++)
-            {
-              if (components[i] == null)
-                continue;
-              Dimension dims = components[i].getMinimumSize();
-              if (dims != null)
-                {
-                  height += dims.height;
-                  width = Math.max(width, dims.width);
-                }
-            }
-          return new Dimension(width, height);
-        }
-      return null;
-    }
-
-    /**
-     * This method returns the preferred layout size. The preferred height is
-     * the sum of all the components'  preferred heights. The preferred width
-     * is the maximum of  all the components' preferred widths.
-     *
-     * @param container The container to measure.
-     *
-     * @return The preferred size.
-     */
-    public Dimension preferredLayoutSize(Container container)
-    {
-      if (container instanceof JSplitPane)
-        {
-          JSplitPane split = (JSplitPane) container;
-          Insets insets = container.getInsets();
-
-          int height = 0;
-          int width = 0;
-          for (int i = 0; i < components.length; i++)
-            {
-              if (components[i] == null)
-                continue;
-              Dimension dims = components[i].getPreferredSize();
-              if (dims != null)
-                {
-                  height += dims.height;
-                  width = Math.max(width, dims.width);
-                }
-            }
-          return new Dimension(width, height);
-        }
-      return null;
-    }
-
-    /**
-     * This method sets the bounds of the given component. The y coordinate is
-     * the location given. The x coordinate is the left inset. The height is
-     * the size given. The width is the container size minus the left and
-     * right inset.
-     *
-     * @param c The component to set bounds for.
-     * @param size The height.
-     * @param location The y coordinate.
-     * @param insets The insets to use.
-     * @param containerSize The container's size.
-     */
-    protected void setComponentToSize(Component c, int size, int location,
-                                      Insets insets, Dimension containerSize)
-    {
-      int y = location;
-      int x = insets.left;
-      int h = size;
-      int w = containerSize.width - insets.left - insets.right;
-      c.setBounds(x, y, w, h);
-    }
-
-    /**
-     * This method returns the minimum height of the component at the given
-     * index.
-     *
-     * @param index The index of the component to check.
-     *
-     * @return The minimum height of the given component.
-     */
-    int minimumSizeOfComponent(int index)
-    {
-      Dimension dims = components[index].getMinimumSize();
-      if (dims != null)
-        return dims.height;
-      else
-        return 0;
+      super(SwingConstants.VERTICAL);
     }
   }
 
   /**
    * This class handles FocusEvents from the JComponent.
    *
    * @specnote Apparently this class was intended to be protected,
    *           but was made public by a compiler bug and is now
    *           public for compatibility.
    */
   public class FocusHandler extends FocusAdapter
   {
Index: javax/swing/plaf/basic/BasicSplitPaneDivider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneDivider.java,v
retrieving revision 1.16
diff -u -1 -2 -r1.16 BasicSplitPaneDivider.java
--- javax/swing/plaf/basic/BasicSplitPaneDivider.java	14 Aug 2006 13:40:00 -0000	1.16
+++ javax/swing/plaf/basic/BasicSplitPaneDivider.java	14 Aug 2006 21:39:38 -0000
@@ -996,25 +996,24 @@
                       x = (getWidth() - size) / 2;
                     }
                   else
                     {
                       x = insets.left;
                       y = 0;
                     }
                   
                   leftButton.setBounds(x, y + ONE_TOUCH_OFFSET, size,
                                        size * 2);
                   rightButton.setBounds(x, y + ONE_TOUCH_OFFSET
                                         + ONE_TOUCH_SIZE * 2, size, size * 2);
-                  System.err.println("leftButton:" + leftButton.getBounds());
                 }
               else
                 {
                   int size = getHeight() - insets.top - insets.bottom;
                   size = Math.max(size, 0);
                   size = Math.min(size, ONE_TOUCH_SIZE);
                   int x, y;
                   if (centerOneTouchButtons)
                     {
                       x = insets.left;
                       y = (getHeight() - size) / 2;
                     }
Index: javax/swing/plaf/metal/MetalSplitPaneDivider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java,v
retrieving revision 1.10
diff -u -1 -2 -r1.10 MetalSplitPaneDivider.java
--- javax/swing/plaf/metal/MetalSplitPaneDivider.java	14 Aug 2006 13:40:01 -0000	1.10
+++ javax/swing/plaf/metal/MetalSplitPaneDivider.java	14 Aug 2006 21:39:38 -0000
@@ -31,46 +31,61 @@
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 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.metal;
 
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Insets;
 
 import javax.swing.JButton;
 import javax.swing.JSplitPane;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.plaf.basic.BasicSplitPaneDivider;
 
 /**
  * The divider that is used by the [EMAIL PROTECTED] MetalSplitPaneUI}.
  *
  * @author Roman Kennke ([EMAIL PROTECTED])
  */
 class MetalSplitPaneDivider extends BasicSplitPaneDivider
 {
   /**
    * The button pixel data, as indices into the colors array below.
+   * This is the version for 'left' buttons.
+   *
+   * This is slightly different from the icon in Sun's version, it is
+   * one pixel smaller and is more consistent with BUTTON_SPRITE_R.
+   */
+  static final byte[][] BUTTON_SPRITE_L = {{ 0, 0, 0, 2, 0, 0, 0, 0 },
+                                           { 0, 0, 2, 1, 1, 0, 0, 0 },
+                                           { 0, 2, 1, 1, 1, 1, 0, 0 },
+                                           { 2, 1, 1, 1, 1, 1, 1, 0 },
+                                           { 0, 3, 3, 3, 3, 3, 3, 3 }};
+
+  /**
+   * The button pixel data, as indices into the colors array below.
+   * This is the version for 'right' buttons.
    */
-  static final byte[][] BUTTON_SPRITE = {{ 0, 0, 0, 2, 2, 0, 0, 0, 0 },
-                                         { 0, 0, 2, 1, 1, 1, 0, 0, 0 },
-                                         { 0, 2, 1, 1, 1, 1, 1, 0, 0 },
-                                         { 2, 1, 1, 1, 1, 1, 1, 1, 0 },
-                                         { 0, 3, 3, 3, 3, 3, 3, 3, 3 }};
+  static final byte[][] BUTTON_SPRITE_R = {{ 2, 2, 2, 2, 2, 2, 2, 2 },
+                                           { 0, 1, 1, 1, 1, 1, 1, 3 },
+                                           { 0, 0, 1, 1, 1, 1, 3, 0 },
+                                           { 0, 0, 0, 1, 1, 3, 0, 0 },
+                                           { 0, 0, 0, 0, 3, 0, 0, 0 }};
 
   private class MetalOneTouchButton
     extends JButton
   {
     /**
      * Denotes a left button.
      */
     static final int LEFT = 0;
 
     /**
      * Denotes a right button.
      */
@@ -124,98 +139,60 @@
           colors[1] = MetalLookAndFeel.getPrimaryControlDarkShadow();
           colors[2] = MetalLookAndFeel.getPrimaryControlInfo();
           colors[3] = MetalLookAndFeel.getPrimaryControlHighlight();
 
           // Fill background.
           g.setColor(getBackground());
           g.fillRect(0, 0, getWidth(), getHeight());
 
           // Pressed buttons have slightly different color mapping.
           if (getModel().isPressed())
             colors[1] = colors[2];
 
+          byte[][] sprite;
           if (direction == LEFT)
+            sprite = BUTTON_SPRITE_L;
+          else
+            sprite = BUTTON_SPRITE_R;
+
+          if (orientation == JSplitPane.VERTICAL_SPLIT)
             {
-              if (orientation == JSplitPane.VERTICAL_SPLIT)
+              // Draw the sprite as it is.
+              for (int y = 0; y < sprite.length; y++)
                 {
-                  // Draw the sprite as it is.
-                  for (int y = 0; y < BUTTON_SPRITE.length; y++)
+                  byte[] line = sprite[y];
+                  for (int x = 0; x < line.length; x++)
                     {
-                      byte[] line = BUTTON_SPRITE[y];
-                      for (int x = 0; x < line.length; x++)
+                      int c = line[x];
+                      if (c != 0)
                         {
-                          int c = line[x];
-                          if (c != 0)
-                            {
-                              g.setColor(colors[c]);
-                              g.fillRect(x, y, 1, 1);
-                            }
-                        }
-                    }
-                }
-              else
-                {
-                  // Draw the sprite with swapped X and Y axis.
-                  for (int y = 0; y < BUTTON_SPRITE.length; y++)
-                    {
-                      byte[] line = BUTTON_SPRITE[y];
-                      for (int x = 0; x < line.length; x++)
-                        {
-                          int c = line[x];
-                          if (c != 0)
-                            {
-                              g.setColor(colors[c]);
-                              g.fillRect(y, x, 1, 1);
-                            }
+                          g.setColor(colors[c]);
+                          g.fillRect(x + 1, y + 1, 1, 1);
                         }
                     }
                 }
             }
           else
             {
-              if (orientation == JSplitPane.VERTICAL_SPLIT)
-                {
-                  // Draw sprite mirrored.
-                  int ySize = BUTTON_SPRITE.length;
-                  for (int y = 0; y < ySize; y++)
-                    {
-                      byte[] line = BUTTON_SPRITE[y];
-                      int xSize = line.length;
-                      for (int x = 0; x < xSize; x++)
-                        {
-                          int c = line[x];
-                          if (c != 0)
-                            {
-                              g.setColor(colors[c]);
-                              g.fillRect(xSize - x - 1, ySize - y - 1, 1, 1);
-                            }
-                        }
-                    }
-                }
-              else
+              // Draw the sprite with swapped X and Y axis.
+              for (int y = 0; y < sprite.length; y++)
                 {
-                  // Draw sprite mirrored and X-Y-swapped.
-                  int ySize = BUTTON_SPRITE.length;
-                  for (int y = 0; y < ySize; y++)
+                  byte[] line = sprite[y];
+                  for (int x = 0; x < line.length; x++)
                     {
-                      byte[] line = BUTTON_SPRITE[y];
-                      int xSize = line.length;
-                      for (int x = 0; x < xSize; x++)
+                      int c = line[x];
+                      if (c != 0)
                         {
-                          int c = line[x];
-                          if (c != 0)
-                            {
-                              g.setColor(colors[c]);
-                              g.fillRect(ySize - y - 1, xSize - x - 1, 1, 1);
-                            }
+                          g.setColor(colors[c]);
+                          g.fillRect(y + 1, x + 1, 1, 1);
                         }
                     }
                 }
             }
         }
     }
   }
 
   /** The dark color in the pattern. */
   Color dark;
 
   /** The light color in the pattern. */
@@ -252,25 +229,28 @@
 
     if (splitPane.hasFocus())
       {
         g.setColor(UIManager.getColor("SplitPane.dividerFocusColor"));
         g.fillRect(0, 0, s.width, s.height);
       }
     
     // Paint border if one exists.
     Border border = getBorder();
     if (border != null)
       border.paintBorder(this, g, 0, 0, s.width, s.height);
 
-    MetalUtils.fillMetalPattern(splitPane, g, 2, 2, s.width - 4, s.height - 4,
+    Insets i = getInsets();
+    MetalUtils.fillMetalPattern(splitPane, g, i.left + 2, i.top + 2,
+                                s.width - i.left - i.right - 4,
+                                s.height - i.top - i.bottom - 4,
                                 light, dark);
     super.paint(g);
   }
 
   protected JButton createLeftOneTouchButton()
   {
     JButton b = new MetalOneTouchButton(MetalOneTouchButton.LEFT);
     b.setMinimumSize(new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE));
     b.setRequestFocusEnabled(false);
     return b;
   }
 

Reply via email to