Native Look and Feel in Java
By default a Swing application or applet does not have the native look and feel of the operating system. This tutorial shows how to modify your application to use the correct look and feel for the platform.
By default the look and feel is Aqua in Java 1.5 and Metal in prior versions. The following image shows a sample of an application using the default look and feel of Aqua in Java 1.5:
If you want your application to have the native look and feel instead of the generic Aqua or Metal look and feel, you can simply add a few lines of code to your application to set the native look and feel.
tryAfter adding the code, the application the will now have the native look and feel of the platform. Here is the resulting application running on an application running on Windows XP.
{
//Tell the UIManager to use the platform look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{
//Do nothing
}

If you have Windows XP set to use the Windows Classic style, the application will have the correct look and feel as seen below.

Related Links:
JTabbedPane in Windows XP

2 comments:
Ok and can i use the Windows XP LookAndFeel even if my OS is Windows 2000 ?
dany,
You can't use the WinXP LnF if your OS is Win2k... "native look and feel" means exactly that.. i.e. make your app look "native".
Post a Comment