JDK-8134829 : jscrollbar thumb vanishes in Nimbus UI
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u60,8u66,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2015-08-28
  • Updated: 2015-09-01
  • Resolved: 2015-09-01
Related Reports
Duplicate :  
Description
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


Comments
Run the attached test case (ThumbTest.java) in Windows 7 (64-bit) Checked this for JDK 7u85, 8u51, 8u60, 9 ea b78. Result: =========== 7u85: OK 8u51: OK 8u60: FAIL 8u66 ea b02: FAIL 9 ea b78: FAIL Steps to reproduce: =================== 1. Compile and run the attached program 2. Resize the window to make it smaller. 3. The vertical scrollbar disappears in 8u60, 8u66 ea b02, and 9 ea b78. This is a regression in 8u60, 8u66 ea b02, and 9 ea b78 as checked. Further, this looks like a duplicate of JDK-8134827
01-09-2015