Skip to content

Possible to remove Title bar from JFileChooser?

I am trying to display a simple JFileChooser that has no Titlebar. Below is the example code:

package ca.customfilepicker.main;
import java.awt.Component;
import java.awt.HeadlessException;

import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFileChooser;

class CustomFileChooser


    public static void main(String args[]) {

        JFileChooser chooser = new JFileChooser() {
            protected JDialog createDialog(Component parent) throws HeadlessException {
                JDialog diag = super.createDialog(parent);
                return diag;


So essentially I want the Border I set to be the top level Title bar. Example image:

So far I have had zero luck achieving this, nor found any others looking for a similar appearance. Appreciate the help! Cheers



The JFileChooser is just a Swing component. It can be added to any Container.

So you could create an undecorated JDialog and add an instance of the JFileChooser to the dialog.

The problem is now that the “Open” and “Cancel” buttons won’t close the dialog, so you would need to to that manually. You could probably override the “approveSelection()andcancelSelection()` methods of the JFileChooser.

I would guess the logic would be to invoke super.approveSelection() or super.cancelSelection() and then use the SwingUtilities.windowForComponent(...) method to get the parent window and then invoke dispose() on the window.

User contributions licensed under: CC BY-SA
3 People found this is helpful