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
  • 166,747
  • 40
  • 210
  • 420
Oleg Vazhnev
  • 22,231
  • 49
  • 161
  • 290

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
  • 79,064
  • 10
  • 147
  • 183
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
  • 166,747
  • 40
  • 210
  • 420
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,279
  • 8
  • 53
  • 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
  • 12