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

Scrollbar thumb appears when JScrollBar is longer 1000px (only in Nimbus L&F)

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_151"
      Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
      Java HotSpot(TM) Client VM (build 25.151-b12, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]


      A DESCRIPTION OF THE PROBLEM :
      I have a JScrollBar with extent equal to total range. It shouldn't display the thumb since
      no scrolling is possible (Extent == Maximum - Minimum). And it doesn't unitil JScrollBar is resized to be longer than approximately 1000px. In this case a 1000px-long thumb is drawn.

      I see this behaviour ONLY when I am using Nimbus L&F. It behaves similarily with JDK 8u131.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JFrame frame with Nimbus Look and Feel, provide it with default BorderLayout. Place horizontal JScrollBar inside the frame with BorderLayout.CENTER position, set scrollbar model parameters to be "minimum == 0, maximum == 100, extent == 100".

      Run the frame, when frame with scrollbar appears --- stretch it horizontally to be wider than 1200 px.


       

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There shouldn't be visible thumb in scrollbar.
      ACTUAL -
      There is a thumb when the scrollbar is long enough.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.BoundedRangeModel;

      public class NimbusFrame extends javax.swing.JFrame {

      public NimbusFrame() {
      initComponents();

      BoundedRangeModel model = xScrollBar.getModel();
      model.setMinimum(0);
      model.setMaximum(100);
      model.setExtent(100);

      }

      @SuppressWarnings("unchecked")
          // <editor-fold defaultstate="collapsed" desc="Generated Code">
          private void initComponents() {

              xScrollBar = new javax.swing.JScrollBar();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

              xScrollBar.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
              getContentPane().add(xScrollBar, java.awt.BorderLayout.CENTER);

              pack();
          }// </editor-fold>

      public static void main(String args[]) {
      try {
      for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
      if ("Nimbus".equals(info.getName())) {
      javax.swing.UIManager.setLookAndFeel(info.getClassName());
      break;
      }
      }
      }
      catch (ClassNotFoundException ex) {
      java.util.logging.Logger.getLogger(NimbusFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      }
      catch (InstantiationException ex) {
      java.util.logging.Logger.getLogger(NimbusFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      }
      catch (IllegalAccessException ex) {
      java.util.logging.Logger.getLogger(NimbusFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      }
      catch (javax.swing.UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(NimbusFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      }
      //</editor-fold>
      //</editor-fold>

      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() {
      @Override
      public void run() {
      new NimbusFrame().setVisible(true);
      }
      });
      }
                          
          private javax.swing.JScrollBar xScrollBar;
                     
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use another Look And Feel. Or manually disable the scrollBar when extent equals to total range.

        1. Capture.PNG
          Capture.PNG
          4 kB
        2. metallnf.png
          metallnf.png
          18 kB
        3. motiflnf.png
          motiflnf.png
          23 kB
        4. NimbusFrame.java
          2 kB

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: