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

JSlider has problems with a range greater than maximum integer

XMLWordPrintable

    • beta
    • x86
    • windows_nt



      Name: krT82822 Date: 03/10/2000


      10 Mar 2000, eval1127@eng -- the constructor apparently does no bounds-checking, which seems to contribute to the problem. Can't find other bugs open
      that address this issue, so am filing one.

      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
      Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

      1. Create a JSlider with a minimum and maximum value such that the range of the
      slider is greater than the maximum (positive) value for integers (2^31) ie.
      maximum - minumum > 2^31.
      The slider exhibits strange behaviour. The slider value jumps between the
      minimum and maximum values when the slider cursor is dragged. Other values can
      be obtained though when clicking on the slider bar.

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

      public class JSliderTest extends JFrame {

      JSlider slider;
      JLabel label;

      public static void main(String args[]) {

      JSliderTest mainFrame = new JSliderTest();
      }

      public JSliderTest () {

                      slider = new JSlider(-1073741824, 1073741824, 0);
      label = new JLabel(Integer.toString(slider.getValue()));

      this.getContentPane().setLayout(new GridLayout(2, 1));
      this.getContentPane().add(slider);
      this.getContentPane().add(label);

      this.setSize(200, 100);
      this.setVisible(true);



      slider.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent evt) {
      label.setText(Integer.toString(slider.getValue()));
      }
      } );
      }
      }
       
      3., 4., 5., N/A
      (Review ID: 102124)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: