Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4344469

unix: JSlider knob can occupy incorrect position

    • x86, sparc
    • linux, solaris_2.6



      Name: iaR10016 Date: 06/09/2000



      JDK version:
      java version "1.3.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b07)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b04, mixed mode)

      JSlider knob can occupy position not corresponded to JSlider Value meaning when it's Extent is
      greater then 0 and knob was dragged by mouse.

      This effect appears under Linux 1.3 JDK and Solaris 1.3 JDK.

      Java 2 Platform SE v1.3 specification reads:

      ...

      JSlider
      A component that lets the user graphically select a value by sliding a knob within a bounded
      interval.
      ...
      public interface BoundedRangeModel
      Defines the data model used by components like Sliders and ProgressBars. Defines four
      interrelated integer properties: minimum, maximum, extent and value. These four
      integers define two nested ranges like this:
      minimum <= value <= value+extent <= maximum
      The outer range is minimum,maximum and the inner range is value,value+extent. The
      inner range must lie within the outer one, i.e. value must be less than or equal to maximum
      and value+extent must greater than or equal to minimum, and maximum must be greater
      than or equal to minimum.
      ...

      The frame window of the following test contains JSlider component with Extent = 20,
      minimumValue = 0, maximumValue = 100. In the title of the frame you can see JSlider Extent and
      Value meanings. The Value can be in the range from 0 to 80. If you'll select JSlider knob and
      use keyboard (Left, Right, Home, End, PgUp, PgDn keys) to move the knob, you can not reach
      slider's label that corresponds value greater then 80. The knob position corresponds meaning of
      Value in this case. But you can reach incorrect knob position using mouse. If you drop slider knob
      to right as far as possible, the knob position will corresponds maximumValue (100), although
      really the Value is 80.

      -------------------- test.java ----------------------------------------------------------

      import javax.swing.*;
      import javax.swing.event.*;
      import java.awt.*;

      public class test extends JFrame {
          JSlider aSlider;

          public test() {
              super("JSlider test (Extent=20)");
              aSlider = new JSlider(0);
              aSlider.setMajorTickSpacing(10);
              aSlider.setExtent(20);
              aSlider.setPaintLabels(true);
              aSlider.setPaintTicks(true);
              getContentPane().add(aSlider,BorderLayout.CENTER);
              aSlider.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    setTitle("Extent="+aSlider.getExtent()+", Value="+aSlider.getValue()); }
               });
          }

          public static void main(String[] args) {
              JFrame frame = new test();
              frame.setSize(new Dimension(300,100));
              frame.setVisible(true);
          }
      }

      ------------------------------------------------------------------------------------

      JCK 1.3 runtime test api/javax_swing/interactive/JSliderTests.html#JSlider
      fails due to this bug.

      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            irasunw Ira Ira (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: