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

jscrollbar thumb vanishes in Nimbus UI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 8u60, 8u66, 9
    • client-libs

      FULL PRODUCT VERSION :
      only since jdk1.8.0_60

      ADDITIONAL OS VERSION INFORMATION :
      opensuse 13.2
      windows 7

      A DESCRIPTION OF THE PROBLEM :
      If the height of show items in JScrollPane is big enough that the size of the thumb would go under a certain limit the thumb vanishes completely (althought there is enough space left to show it as it had been in all earlier versions)

      REGRESSION. Last worked in version 8u51

      ADDITIONAL REGRESSION INFORMATION:
      java(TM) SE Runtime Environment (build 1.8.0_60-b27)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile and run the appened class, step to item numbers 120

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the thumb continues to be shown
      ACTUAL -
      the thumb disappears

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error messages

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package demo;

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


      public class ThumbTest extends JFrame
      {
      JPanel mainPanel;
      JList testList;
      JButton buttonPlus;
      JButton buttonMinus;
      JLabel labelCount;
      NumberListModel listModel;

      final int startCount = 118;
      final int leapCount = 1;


      private class NumberListModel extends DefaultListModel<Integer>
      {
      public void init(int size)
      {
      for (int i = 0; i < size; i++)
      {
      addElement(i);
      }
      }

      public void extend()
      {
      for (int i = 0; i < leapCount; i++)
      addElement(getSize());
      }

      public void shorten()
      {
      for (int i = 0; i < leapCount; i++)
      removeElement(getSize()-1);
      }
      }




      public ThumbTest()
      {
      super("ThumbTest");

      initMainPanel();

      getContentPane().add( mainPanel );

      //setSize(new java.awt.Dimension(300, 500));
      pack();
      setVisible(true);

      }


      private void initMainPanel()
      {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


      listModel = new NumberListModel();
      listModel.init( startCount );
      labelCount = new JLabel("" + startCount );

      testList = new JList(listModel);

      buttonPlus = new JButton("+");
      buttonPlus.addActionListener(new ActionListener(){
      @Override
      public void actionPerformed(ActionEvent e)
      {
      listModel.extend();
      labelCount.setText( "" + (listModel.getSize()) );
      }
      }
      );

      JScrollPane scrollpane = new JScrollPane(testList)

      ;


      scrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
      scrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);


      buttonMinus = new JButton("-");
      buttonMinus.addActionListener(new ActionListener(){
      @Override
      public void actionPerformed(ActionEvent e)
      {
      listModel.shorten();
      labelCount.setText( "" + (listModel.getSize()) );
      }
      }
      );



      mainPanel = new JPanel();
      GroupLayout mainLayout = new GroupLayout(mainPanel);
      mainPanel. setLayout(mainLayout);

      mainLayout.setVerticalGroup( mainLayout.createSequentialGroup()
      .addGap(20)
      .addComponent(scrollpane, 200, 300, 400)
      .addGap(20)
      .addGroup( mainLayout.createParallelGroup( GroupLayout.Alignment.CENTER )
      .addComponent(buttonPlus, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
      .addComponent(buttonMinus, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
      .addComponent(labelCount, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
      )
      .addGap(20)
      );

      mainLayout.setHorizontalGroup( mainLayout.createParallelGroup()
      .addGroup( mainLayout.createSequentialGroup()
      .addGap(20)
      .addComponent(scrollpane, 200, 200, 200)
      .addGap(20)
      )
      .addGroup( mainLayout.createSequentialGroup()
      .addGap(10)
      .addComponent(buttonPlus, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
      .addGap(10)
      .addComponent(buttonMinus, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
      .addGap(20)
      .addComponent(labelCount, 60, 60, 60)

      )
      );

      }



      public static void main(String[] args)
      {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
      {
      System.out.println("LookAndFeelInfo info " + info.getName());




      if ("Nimbus".equals(info.getName()))
      {
      System.out.println("setting Nimbus look&feel");
      try{
      UIManager.setLookAndFeel(info.getClassName());

      UIManager.getDefaults().put("ScrollBar.thumbHeight", 10);
      UIManager.getDefaults().put("ScrollBar.minimumThumbSize", new javax.swing.plaf.DimensionUIResource(5, 5));
      //standard new javax.swing.plaf.DimensionUIResource(29, 29));



      }
      catch (Exception ex)
      {
      System.out.println("" + ex);
      }
      }



      }

      System.out.println(" thumb height : " + UIManager.getDefaults().get("ScrollBar.thumbHeight"));
      System.out.println(" thumb height : " + UIManager.getDefaults().get("ScrollBar.minimumThumbSize"));

      SwingUtilities.invokeLater(new Runnable(){

      public void run()
      {
      new ThumbTest();
      }
      }
      );
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I didn't find one

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: