3

When I'm using JFileChooser application in my program on Windows 7 it display such window:

Metal JFileChooser

But when I run the JWS File Chooser Demo it displays much better window:

JWS File Chooser Demo

Why?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305

4 Answers4

8

Because the demo doesn't use JFileChooser; it uses javax.jnlp.FileOpenService, which uses the native OS's file dialog. The source code for that demo is here, check it out.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
5

The major difference could be solved by using the native look and feel. See the main() of FileBro for how to do that.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
5

The Oracle Java Web Start app, is actually using the JNLP API instead of Swing's JFileChooser.

Here is a link: http://download.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/jnlpAPI.html

jzd
  • 23,473
  • 9
  • 54
  • 76
0

use this code

          try
        {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        }
        catch (ClassNotFoundException e1)
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        catch (InstantiationException e1)
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        catch (IllegalAccessException e1)
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        catch (UnsupportedLookAndFeelException e1)
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
Kernelzero
  • 113
  • 13