JDK-8134828 : Scrollbar thumb disappears with Nimbus L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u60,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2015-08-27
  • Updated: 2016-04-27
  • Resolved: 2015-10-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u101Fixed 9 b94Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 7 Enterprise x64
Version	6.1.7601 Service Pack 1 Build 7601

EXTRA RELEVANT SYSTEM CONFIGURATION :
Display Adapter: Intel(R) HD Graphics 4600
Display Driver Version: 9.18.10.3272

A DESCRIPTION OF THE PROBLEM :
When using Nimbus L&F, the scrollbar thumb disappears when it becomes too small (i.e. when the ratio of visible height to total height is too low).  It is still possible to interact with the invisible scrollbar thumb.  Both horizontal and vertical scrollbars exhibit this behavior.  Other look-and-feels are not affected.

REGRESSION.  Last worked in version 8u45

ADDITIONAL REGRESSION INFORMATION: 
I can always reproduce this on my machine.  My colleague (using JRE/JDK 8u45) could not reproduce it on his machine.  I'm unable to downgrade JRE/JDK on my own machine at this time to verify that this is a regression, but I don't recall seeing this problem before.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attached sample code contains a JTextArea inside a JScrollPane, presented in a Window form.

1. Compile and run the attached example
2. Resize the window to make it smaller, until scrollbar thumbs reach minimum width

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Scrollbar button remains small but visible.
ACTUAL -
Scrollbar button disappears. See screen capture of the behavior (GIF): http://i.imgur.com/Hq1ME58.gif

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package nimbusscrollbarpoc;

public class MainWindow extends javax.swing.JFrame {

    public MainWindow() {
        initComponents();

        // Generate many lines of text
        String line = "0123456789" + System.getProperty("line.separator");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 500; i++) {
            sb.append(line);
        }
        this.textArea.setText(sb.toString());
    }

    @SuppressWarnings("unchecked")                      
    private void initComponents() {
        scrollPane = new javax.swing.JScrollPane();
        textArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        textArea.setColumns(20);
        textArea.setRows(5);
        scrollPane.setViewportView(textArea);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }                      

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        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(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(() -> {
            new MainWindow().setVisible(true);
        });
    }
                  
    private javax.swing.JScrollPane scrollPane;
    private javax.swing.JTextArea textArea;               
}

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


Comments
[ https://en.wikipedia.org/wiki/Scrollbar ] 'Thumb' is the recognized term for the scroll bar element.
02-11-2015

The fix is safe, we have several customer's escalations for this issue. SQE OK to take it to CPU16_01.
02-11-2015

Post discussion with Alexey. {{ I'd say it's better included in CPU as well: it's not great to use UI where you can't see scroll bar thumb even though there's enough of space to paint one. Besides the invisible thumb, the scroll bar remains operable. The risk is minimal: only Nimbus L&F is affected. But this could be used against including it: Nimbus is not so popular. }} Making the request for the CPU and PSU. Critical Request: - Fix for Release : 8u71 and 8u72 - Justification : Regression from fix to JDK-8041642 - Risk Analysis : Low, changes in code are not risky - Webrev : http://cr.openjdk.java.net/~ssadetsky/8134828/webrev.00/ - Testing (done/to-be-done) : newly added regression test passes - Back ports (done/to-be-done) : backported to 8u76 - FX Impact : none
30-10-2015

Critical Request: - Fix for Release : 8u72 - Justification : Regression from fix to JDK-8041642 - Risk Analysis : Low, changes in code are not risky - Webrev : http://cr.openjdk.java.net/~ssadetsky/8134828/webrev.00/ - Testing (done/to-be-done) : newly added regression test passes - Back ports (done/to-be-done) : backported to 8u76 - FX Impact : none
30-10-2015

Thumb minimal size is 29 while thumb's painter insets are 15+15. So the thumb image should be shrunk 30->29. But JDK-8041642 fix introduced protection for painter's image shrinking because it causes distortion of the progress bar. Since Nimbus thumb image doesn't have light border its shrinking distortion is not noticeable.
02-09-2015

Run the attached test case (MainWindow.java) in Windows 7 (64-bit) Checked this for JDK 8u51, 8u60, 9 ea b78 Result: =========== 8u51: OK 8u60: FAIL 9 ea b78: FAIL Steps to reproduce: ============== 1. Compile and run the attached program 2. Resize the window to make it smaller, until scrollbar thumbs reach minimum width 3. The vertical scrollbar remains visible with 8u51, but with 8u60 and 9 ea b78 it does not appear as expected. This is a regression in 8u60 and 9 ea b78 as checked. Further, this looks like a duplicate of JDK-8134827
01-09-2015