JDK-7079960 : JFileChooser Up One Level button not working in Windows XP w/System Look/Feel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-08-16
  • Updated: 2012-09-06
  • Resolved: 2011-08-18
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
U:\>java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP 32 bit

A DESCRIPTION OF THE PROBLEM :
When using the System Look and Feel in Windows XP and opening a JFileChooser, the "up one level" button does not work as it does in other looks and feels. Upon opening the file selection dialog, immediately pressing the button will do nothing. If you then click inside the file listing area (or press one of the other buttons), the button then begins to work. In the Nimbus and default look and feels, the button works immediately without any other input being necessary.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The simplest way I was able to reproduce this bug was by creating a main method in a test class that sets the look and feel to the system look and feel, then creates a JFileChooser, sets it to directories only, and displays it. You will then see that the text in the text field is highlighted and that clicking the "up one level" button does nothing. If you click almost anywhere else, the text will be un-selected, and the button will then work as it should.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You should be able to use the "up one level" button at any time. During testing, this bug caused testers to say that the button is broken since functionality is different in applications using a different look and feel.
ACTUAL -
The button only works after clicking somewhere else first.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
    public static void main(String[] args)
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch(Exception e)
        {
        }
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int f = fc.showOpenDialog(null);

    }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Switched to a different look and feel to avoid this bug. Nimbus looks nicer anyway.