简体   繁体   中英

Hide the “choosable file filter” widget in a JFileChooser

How do I hide the "choosable file filter widget" in a JFileChooser? By "choosable file filter widget", I mean the panel below containing the words "File Format".

在此处输入图片说明

There's lots of info in the docs on how to modify the specific filters that appear in the widget, but I can't figure out how to hide it entirely.

I'm using the JFileChooser to select a directory, so the widget's unnecessary.

Any ideas?

EDIT

In the end I took Andrew Thompson's suggestion and set the filter chooser to display the text "directories only". In case it helps anyone, I used the following code:

        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fc.setFileFilter( new FileFilter(){

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

            @Override
            public String getDescription() {
                return "Directories only";
            }

        });

Alternately fill it with a "Directories only" text. Then it will appear as the user expects it, with instructions.


File Format: Any Folder


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM