JDK-8029536 : JFileChooser filter uses .toString() instead of getDescription() for filter text on GTK laf
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u71,7u45,7u51,8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2013-12-04
  • Updated: 2015-06-30
  • Resolved: 2014-11-30
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
8u40Fixed 9 b44Fixed
Related Reports
Relates :  
Description
1. Set look and feel to GTKLookAndFeel
2. Update JFileChooser component with SwingUtilities.updateComponentTreeUI.

Result: Filter changed to a default toString() output
Expected: Look and feel changed, filter text remains the same
Reproducible: always 

Also reproducible if look and feel is changed when JFileChooser is already shown.
How to reproduce (same file attached):

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author lans
 */

public class FilterTest {
    public static void main(String... args) throws Exception {
        JFileChooser chooser = new JFileChooser();
        chooser.setAcceptAllFileFilterUsed(false);
        chooser.addChoosableFileFilter(new FileFilter() {

            @Override
            public boolean accept(File f) {
                return true;
            }

            @Override
            public String getDescription() {
                return "Whatever";
            }
        });
        javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        SwingUtilities.updateComponentTreeUI(chooser);
        chooser.showOpenDialog(null);
    }
}



Comments
Please provide full test name in the swing ws, which is affected by this bug.
18-08-2014

The fix is very simple: the GTKFileChooserUI.FilterComboBoxRenderer class must not implement UIResource (see similar classes in other L&Fs). - public class FilterComboBoxRenderer extends DefaultListCellRenderer implements UIResource { + public class FilterComboBoxRenderer extends DefaultListCellRenderer {
05-12-2013

is it reproducible on 7 GA (b145) ?
05-12-2013

EVALUATION: Other releases tested: 7u40b62, 7u45b18 (GA) Other platforms with GTK: Solaris, reproduced. Earliest version tested: 5u61 Other look and feels: Reproducible only with GTL look and feel. Others (Metal, Nimbus, Motif, Windows, WindowsClassic) are ok. Looks like that it's a look and feel problem.
05-12-2013

what is the earliest release to reproduce?
05-12-2013

The issue is not reproducible with Windows, WindowsClassic, Nimbus, Motif & Metal L&Fs. Seems that GTK L&F loses FilterComboBoxRenderer on UI updating.
05-12-2013

please reopen once you add info about reproducibility on other platforms and releases (7u40? 7 GA?)
05-12-2013

what is introduced in release? is it regression?
05-12-2013

please evaluate this bug.
05-12-2013

Reproduces bug when JFileChooser is already shown
04-12-2013