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

JSlider value should not change on right-click

    Details

    • Subcomponent:
    • Resolved In Build:
      b27
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Not verified

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_02"
      Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If you press the right mouse button on the slider track, the slider value changes. This is not Windows default behavior. One bad example: You want to open a context menu on the slider, and with the same click the value changes. The slider value should only change, if the left mouse button is pressed on the slider track. This could be solved by adding an if(e.getButton != MouseEvent.BUTTON3) to the TrackListener of BasicSliderUI.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JSlider value should not change when the right mouse button is clicked on the slider track.

      ---------- BEGIN SOURCE ----------
      import java.lang.*;

      public class SliderTest extends javax.swing.JFrame {
          

          public SliderTest() {
              initComponents();
          }
          

          // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
          private void initComponents() {
              jSlider1 = new javax.swing.JSlider();
              jTextField1 = new javax.swing.JTextField();
              jLabel1 = new javax.swing.JLabel();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
              jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
                  public void stateChanged(javax.swing.event.ChangeEvent evt) {
                      jSlider1StateChanged(evt);
                  }
              });

              jTextField1.setColumns(5);

              jLabel1.setText("Slider Value");

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                          .addGroup(layout.createSequentialGroup()
                              .addGap(52, 52, 52)
                              .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                          .addGroup(layout.createSequentialGroup()
                              .addGap(8, 8, 8)
                              .addComponent(jLabel1)
                              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                              .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                      .addContainerGap(55, Short.MAX_VALUE))
              );
              layout.setVerticalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addGap(27, 27, 27)
                      .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                          .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addComponent(jLabel1))
                      .addContainerGap())
              );
              pack();
          }// </editor-fold>

          private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {
              jTextField1.setText(""+jSlider1.getValue());
          }
          
          public static void main(String args[]) {
              java.awt.EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      new SliderTest().setVisible(true);
                  }
              });
          }
          
          // Variables declaration - do not modify
          private javax.swing.JLabel jLabel1;
          private javax.swing.JSlider jSlider1;
          private javax.swing.JTextField jTextField1;
          // End of variables declaration
          
      }
      ---------- END SOURCE ----------

      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            • Assignee:
              rupashka Pavel Porvatov (Inactive)
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: