Index: trunk/src/scriptbuilder/gui/drawers/RangeSliderUI.java
===================================================================
--- trunk/src/scriptbuilder/gui/drawers/RangeSliderUI.java	(revision 27)
+++ trunk/src/scriptbuilder/gui/drawers/RangeSliderUI.java	(revision 84)
@@ -176,17 +176,7 @@
         // Calculate upper thumb location.  The thumb is centered over its
         // value on the track.
-        if (slider.getOrientation() == JSlider.HORIZONTAL)
-        {
             int upperPosition = xPositionForValue(slider.getValue() + slider.getExtent());
             upperThumbRect.x = upperPosition - (upperThumbRect.width / 2);
             upperThumbRect.y = trackRect.y;
-
-        }
-        else
-        {
-            int upperPosition = yPositionForValue(slider.getValue() + slider.getExtent());
-            upperThumbRect.x = trackRect.x;
-            upperThumbRect.y = upperPosition - (upperThumbRect.height / 2);
-        }
     }
 
@@ -248,6 +238,4 @@
         Rectangle trackBounds = trackRect;
 
-        if (slider.getOrientation() == JSlider.HORIZONTAL)
-        {
             // Determine position of selected range by moving from the middle
             // of one thumb to the other.
@@ -272,31 +260,4 @@
             g.translate(-trackBounds.x, -(trackBounds.y + cy));
             g.setColor(oldColor);
-
-        }
-        else
-        {
-            // Determine position of selected range by moving from the middle
-            // of one thumb to the other.
-            int lowerY = thumbRect.x + (thumbRect.width / 2);
-            int upperY = upperThumbRect.x + (upperThumbRect.width / 2);
-
-            // Determine track position.
-            int cx = (trackBounds.width / 2) - 2;
-
-            // Save color and shift position.
-            Color oldColor = g.getColor();
-            g.translate(trackBounds.x + cx, trackBounds.y);
-
-            // Draw selected range.
-            g.setColor(rangeColor);
-            for (int x = 0; x <= 3; x++)
-            {
-                g.drawLine(x, lowerY - trackBounds.y, x, upperY - trackBounds.y);
-            }
-
-            // Restore position and color.
-            g.translate(-(trackBounds.x + cx), -trackBounds.y);
-            g.setColor(oldColor);
-        }
     }
 
@@ -346,28 +307,4 @@
     private void paintUpperThumb(Graphics g)
     {
-//        Remove drawing of upper thumb - jdalbey
-//        Rectangle knobBounds = upperThumbRect;
-//        int w = knobBounds.width;
-//        int h = knobBounds.height;
-//
-//        // Create graphics copy.
-//        Graphics2D g2d = (Graphics2D) g.create();
-//
-//        // Create default thumb shape.
-//        Shape thumbShape = createThumbShape(w - 1, h - 1);
-//
-//        // Draw thumb.
-//        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-//                RenderingHints.VALUE_ANTIALIAS_ON);
-//        g2d.translate(knobBounds.x, knobBounds.y);
-//
-//        g2d.setColor(Color.PINK);
-//        g2d.fill(thumbShape);
-//
-//        g2d.setColor(Color.RED);
-//        g2d.draw(thumbShape);
-//
-//        // Dispose graphics.
-//        g2d.dispose();
     }
 
@@ -414,37 +351,25 @@
             int delta = blockIncrement * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL);
 
-            if (upperThumbSelected)
-            {
-                int oldValue = ((RangeSlider) slider).getUpperValue();
-                ((RangeSlider) slider).setUpperValue(oldValue + delta);
-            }
-            else
-            {
+
+            int oldValue = slider.getValue();
+            slider.setValue(oldValue + delta);
+            
+        }
+    }
+
+    /**
+     * Moves the selected thumb in the specified direction by a unit increment.
+     * This method is called when the user presses one of the arrow keys.
+     */
+    public void scrollByUnit(int direction)
+    {
+        synchronized (slider)
+        {
+            int delta = 1 * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL);
+
+
                 int oldValue = slider.getValue();
                 slider.setValue(oldValue + delta);
-            }
-        }
-    }
-
-    /**
-     * Moves the selected thumb in the specified direction by a unit increment.
-     * This method is called when the user presses one of the arrow keys.
-     */
-    public void scrollByUnit(int direction)
-    {
-        synchronized (slider)
-        {
-            int delta = 1 * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL);
-
-            if (upperThumbSelected)
-            {
-                int oldValue = ((RangeSlider) slider).getUpperValue();
-                ((RangeSlider) slider).setUpperValue(oldValue + delta);
-            }
-            else
-            {
-                int oldValue = slider.getValue();
-                slider.setValue(oldValue + delta);
-            }
+            
         }
     }
@@ -534,16 +459,5 @@
             boolean lowerPressed = false;
             boolean upperPressed = false;
-            if (upperThumbSelected || slider.getMinimum() == slider.getValue())
-            {
-                if (upperThumbRect.contains(currentMouseX, currentMouseY))
-                {
-                    //upperPressed = true;
-                }
-                else if (thumbRect.contains(currentMouseX, currentMouseY))
-                {
-                    lowerPressed = true;
-                }
-            }
-            else
+            if (slider.getMinimum() == slider.getValue())
             {
                 if (thumbRect.contains(currentMouseX, currentMouseY))
@@ -551,7 +465,10 @@
                     lowerPressed = true;
                 }
-                else if (upperThumbRect.contains(currentMouseX, currentMouseY))
+            }
+            else
+            {
+                if (thumbRect.contains(currentMouseX, currentMouseY))
                 {
-                    //upperPressed = true;
+                    lowerPressed = true;
                 }
             }
@@ -560,38 +477,13 @@
             if (lowerPressed)
             {
-                switch (slider.getOrientation())
-                {
-                    case JSlider.VERTICAL:
-                        offset = currentMouseY - thumbRect.y;
-                        break;
-                    case JSlider.HORIZONTAL:
-                        offset = currentMouseX - thumbRect.x;
-                        break;
-                }
+                offset = currentMouseX - thumbRect.x;
                 upperThumbSelected = false;
                 lowerDragging = true;
-                // ALERT: Return from middle of method
-                return;
-            }
-            lowerDragging = false;
-
-            // Handle upper thumb pressed.
-            if (upperPressed)
-            {
-                switch (slider.getOrientation())
-                {
-                    case JSlider.VERTICAL:
-                        offset = currentMouseY - upperThumbRect.y;
-                        break;
-                    case JSlider.HORIZONTAL:
-                        offset = currentMouseX - upperThumbRect.x;
-                        break;
-                }
-                upperThumbSelected = true;
-                upperDragging = true;
-                // ALERT: Return from middle of method
-                return;
-            }
-            upperDragging = false;
+            }
+            else
+            {
+                lowerDragging = false;
+                upperDragging = false;
+            }
         }
 
@@ -621,9 +513,4 @@
                 moveLowerThumb();
                 syncUpperThumb();
-            }
-            else if (upperDragging)
-            {
-                slider.setValueIsAdjusting(true);
-                moveUpperThumb();
             }
         }
@@ -642,62 +529,27 @@
         {
             int thumbMiddle = 0;
-
-            switch (slider.getOrientation())
-            {
-                case JSlider.VERTICAL:
-                    int halfThumbHeight = thumbRect.height / 2;
-                    int thumbTop = currentMouseY - offset;
-                    int trackTop = trackRect.y;
-                    int trackBottom = trackRect.y + (trackRect.height - 1);
-                    int vMax = yPositionForValue(slider.getValue() + slider.getExtent());
-
-                    // Apply bounds to thumb position.
-                    if (drawInverted())
-                    {
-                        trackBottom = vMax;
-                    }
-                    else
-                    {
-                        trackTop = vMax;
-                    }
-                    thumbTop = Math.max(thumbTop, trackTop - halfThumbHeight);
-                    thumbTop = Math.min(thumbTop, trackBottom - halfThumbHeight);
-
-                    setThumbLocation(thumbRect.x, thumbTop); // repaint
-
-                    // Update slider value.
-                    thumbMiddle = thumbTop + halfThumbHeight;
-                    slider.setValue(valueForYPosition(thumbMiddle));
-                    break;
-
-                case JSlider.HORIZONTAL:
-                    int halfThumbWidth = thumbRect.width / 2;
-                    int thumbLeft = currentMouseX - offset;
-                    int trackLeft = trackRect.x;
-                    int trackRight = trackRect.x + (trackRect.width - 1);
-                    int hMax = xPositionForValue(slider.getValue() + slider.getExtent());
-
-                    // Apply bounds to thumb position.
-                    if (drawInverted())
-                    {
-                        trackLeft = hMax;
-                    }
-                    else
-                    {
-                        trackRight = hMax;
-                    }
-                    thumbLeft = Math.max(thumbLeft, trackLeft - halfThumbWidth);
-                    thumbLeft = Math.min(thumbLeft, trackRight - halfThumbWidth);
-
-                    setThumbLocation(thumbLeft, thumbRect.y); //repaint
-
-                    // Update slider value.
-                    thumbMiddle = thumbLeft + halfThumbWidth;
-                    slider.setValue(valueForXPosition(thumbMiddle));
-                    break;
-
-                default:
-                    return;
-            }
+            int halfThumbWidth = thumbRect.width / 2;
+            int thumbLeft = currentMouseX - offset;
+            int trackLeft = trackRect.x;
+            int trackRight = trackRect.x + (trackRect.width - 1);
+            int hMax = xPositionForValue(slider.getValue() + slider.getExtent());
+            System.out.println("Value="+slider.getValue()+"   hMax="+hMax);
+            // Apply bounds to thumb position.
+            if (drawInverted())
+            {
+                trackLeft = hMax;
+            }
+            else
+            {
+                trackRight = hMax;
+            }
+            thumbLeft = Math.max(thumbLeft, trackLeft - halfThumbWidth);
+            thumbLeft = Math.min(thumbLeft, trackRight - halfThumbWidth);
+
+            setThumbLocation(thumbLeft, thumbRect.y); //repaint
+
+            // Update slider value.
+            thumbMiddle = thumbLeft + halfThumbWidth;
+            slider.setValue(valueForXPosition(thumbMiddle));
         }
 
@@ -712,102 +564,28 @@
             int thumbMiddle = 0;
 
-            switch (slider.getOrientation())
-            {
-                case JSlider.HORIZONTAL:
-                    int halfThumbWidth = thumbRect.width / 2;
-                    int sliderLength = xPositionForValue(slider.getExtent());
-                    int thumbLeft = currentMouseX - offset + sliderLength;
-                    int trackLeft = trackRect.x;
-                    int trackRight = trackRect.x + (trackRect.width - 1);
-                    int hMin = xPositionForValue(slider.getValue());
-
-                    // Handle backwards (inverted) slider
-                    if (drawInverted())
-                    {
-                        trackRight = hMin;
-                    }
-                    else
-                    {
-                        trackLeft = hMin;
-                    }
-                    // Apply bounds to thumb position.
-                    thumbLeft = Math.max(thumbLeft, trackLeft - halfThumbWidth);
-                    thumbLeft = Math.min(thumbLeft, trackRight - halfThumbWidth);
-
-                    setUpperThumbLocation(thumbLeft, thumbRect.y);  // repaint slider
-
-                    // Don't Update slider extent.
-                    break;
-
-                default:
-                    return;
-            }
-        }
-
-        /**
-         * Moves the location of the upper thumb, and sets its corresponding
-         * value in the slider.
-         */
-        private void moveUpperThumb()
-        {
-            int thumbMiddle = 0;
-
-            switch (slider.getOrientation())
-            {
-                case JSlider.VERTICAL:
-                    int halfThumbHeight = thumbRect.height / 2;
-                    int thumbTop = currentMouseY - offset;
-                    int trackTop = trackRect.y;
-                    int trackBottom = trackRect.y + (trackRect.height - 1);
-                    int vMin = yPositionForValue(slider.getValue());
-
-                    // Apply bounds to thumb position.
-                    if (drawInverted())
-                    {
-                        trackTop = vMin;
-                    }
-                    else
-                    {
-                        trackBottom = vMin;
-                    }
-                    thumbTop = Math.max(thumbTop, trackTop - halfThumbHeight);
-                    thumbTop = Math.min(thumbTop, trackBottom - halfThumbHeight);
-
-                    setUpperThumbLocation(thumbRect.x, thumbTop);
-
-                    // Update slider extent.
-                    thumbMiddle = thumbTop + halfThumbHeight;
-                    slider.setExtent(valueForYPosition(thumbMiddle) - slider.getValue());
-                    break;
-
-                case JSlider.HORIZONTAL:
-                    int halfThumbWidth = thumbRect.width / 2;
-                    int thumbLeft = currentMouseX - offset;
-                    int trackLeft = trackRect.x;
-                    int trackRight = trackRect.x + (trackRect.width - 1);
-                    int hMin = xPositionForValue(slider.getValue());
-
-                    // Apply bounds to thumb position.
-                    if (drawInverted())
-                    {
-                        trackRight = hMin;
-                    }
-                    else
-                    {
-                        trackLeft = hMin;
-                    }
-                    thumbLeft = Math.max(thumbLeft, trackLeft - halfThumbWidth);
-                    thumbLeft = Math.min(thumbLeft, trackRight - halfThumbWidth);
-
-                    setUpperThumbLocation(thumbLeft, thumbRect.y);
-
-                    // Update slider extent.
-                    thumbMiddle = thumbLeft + halfThumbWidth;
-                    slider.setExtent(valueForXPosition(thumbMiddle) - slider.getValue());
-                    break;
-
-                default:
-                    return;
-            }
+
+            int halfThumbWidth = thumbRect.width / 2;
+            int sliderLength = xPositionForValue(slider.getExtent());
+            int thumbLeft = currentMouseX - offset + sliderLength;
+            int trackLeft = trackRect.x;
+            int trackRight = trackRect.x + (trackRect.width - 1);
+            int hMin = xPositionForValue(slider.getValue());
+
+            // Handle backwards (inverted) slider
+            if (drawInverted())
+            {
+                trackRight = hMin;
+            }
+            else
+            {
+                trackLeft = hMin;
+            }
+            // Apply bounds to thumb position.
+            thumbLeft = Math.max(thumbLeft, trackLeft - halfThumbWidth);
+            thumbLeft = Math.min(thumbLeft, trackRight - halfThumbWidth);
+
+            setUpperThumbLocation(thumbLeft, thumbRect.y);  // repaint slider
+
+            
         }
     }
Index: trunk/src/scriptbuilder/gui/drawers/RangeSlider.java
===================================================================
--- trunk/src/scriptbuilder/gui/drawers/RangeSlider.java	(revision 27)
+++ trunk/src/scriptbuilder/gui/drawers/RangeSlider.java	(revision 84)
@@ -102,5 +102,12 @@
         // Compute new value and extent to maintain upper value.
         int oldExtent = getExtent();
-        int newValue = Math.min(Math.max(getMinimum(), value), oldValue + oldExtent);
+        // Ensure value is greater than minimum allowed
+        int lower = Math.max(getMinimum(), value);
+        // Ensure value is less than maximum allowed
+        // Fix defect that was letting lower thumb go to far right.
+        // Note this still allows the mouse to drag it beyond limit,
+        // but when released it returns to proper place.
+//        int newValue = Math.min(lower, oldValue + oldExtent);
+        int newValue = Math.min(lower, getMaximum() - oldExtent);
         // Hacked to not change the extent (move the entire slider)
         //int newExtent = oldExtent + oldValue - newValue;
Index: trunk/src/scriptbuilder/gui/drawers/RangeSliderDemo.java
===================================================================
--- trunk/src/scriptbuilder/gui/drawers/RangeSliderDemo.java	(revision 26)
+++ trunk/src/scriptbuilder/gui/drawers/RangeSliderDemo.java	(revision 84)
@@ -20,4 +20,5 @@
 
 Copyright (c) 2010 Ernest Yu. All rights reserved.
+https://github.com/ernieyu/Swing-range-slider
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -64,5 +65,5 @@
         rangeSlider.setPreferredSize(new Dimension(240, rangeSlider.getPreferredSize().height));
         rangeSlider.setMinimum(0);
-        rangeSlider.setMaximum(10);
+        rangeSlider.setMaximum(20);
 
         // Add listener to update display.
