Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting java applications to look native on windows - how?

Is it possible to use Java to create apps that look native on Windows? I don't care if the solution is portable or not, because I only plan to target windows users. I am using Scala if that matters.

Sorry for the lack of details, but I have never used Java before so I'm not even sure if this is possible.

like image 306
ryeguy Avatar asked Oct 19 '09 20:10

ryeguy


2 Answers

try {
    // Set the Look and Feel of the application to the operating
    // system's look and feel.
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException e) {
}
catch (InstantiationException e) {
}
catch (IllegalAccessException e) {
}
catch (UnsupportedLookAndFeelException e) {
}

That should set the Look and Feel to the system look and feel. You would do this before any of your GUI code. For example, in your main method.

If you want to learn more about Look and Feels, I would check out the Java Tutorial on them, as suggested by carwash.

like image 122
Thomas Owens Avatar answered Oct 31 '22 18:10

Thomas Owens


Everyone else has posted Swing things, so I'm going to play Devil's advocate and mention SWT.

SWT is a widget toolkit produced by the Eclipse foundation. It is a thin wrapper over the system's native GUI... for Windows, OSX, and various flavors of *nix (Linux, AIX, BSDs?, etc...).

This is the opposite route that Sun's JFC/Swing took, which draws its own components.

like image 32
Powerlord Avatar answered Oct 31 '22 18:10

Powerlord