Is there a way to improve the look of JFileChooser under Ubuntu?

I am making a program that uses JFileChooser. I installed the application using

UIManager.getSystemLookAndFeelClassName ()

Which works great for almost everything under Ubuntu. The only problem I came across is that JFileChooser looks pretty awful: JFileChooser with SystemLookAndFeel

Is there a way to make this look like choosing a default file in Ubuntu? i.e. Desired file chooser dialog

I tried using

UIManager.getCrossPlatformLookAndFeelClassName ()

Which makes the JFileChooser dialog better, but still not native, and it also destroys the rest of the application.

Thank.

+4
source share
4 answers

, JDK gtk1, ubuntu gtk2. , , - gtk2 java. Google? , , , .

+2
+1

Nimbus has a decent selection of files. Although this will affect your entire application, you may like the look.

You can also create your own file if necessary.

+1
source

You can also use SWT instead of rocking.

Does Swing support Windows 7 style files?

The following code from the link above

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class SWTFileOpenSnippet {
    public static void main (String [] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        // Don't show the shell.
        //shell.open ();  
        FileDialog dialog = new FileDialog (shell, SWT.OPEN | SWT.MULTI);
        String [] filterNames = new String [] {"All Files (*)"};
        String [] filterExtensions = new String [] {"*"};
        String filterPath = "c:\\";
        dialog.setFilterNames (filterNames);
        dialog.setFilterExtensions (filterExtensions);
        dialog.setFilterPath (filterPath);
        dialog.open();
        System.out.println ("Selected files: ");
        String[] selectedFileNames = dialog.getFileNames();
        for(String fileName : selectedFileNames) {
            System.out.println("  " + fileName);
        }
        shell.close();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }
}
0
source

All Articles