Programming and general geekiness.

Java Swing is an incredibly easy way of designing a user interface however there’s a major problem with it: the default style is disgusting. The default style that shows up is really horrible because it is designed to be a mix of the designs of Windows, Mac and Linux so that a button is recognizable as a button but not as nice as the default style. Thankfully there is a really easy way to change an app from looking like the one on the right to the default OS style on the left. It is worth noting (as demonstrated by the position of the Next button) that this doesn’t always work brilliantly but that it does look better.

All you have to do is make sure you have imported javax.swing.UIManager and then add the following code before you create the interface:

try 
{
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} 
catch (Exception e) { }

This will fetch the OS’ default style allowing you to easily use it in your application. On Mac this application’s menu should display at the top rather than in the window itself, thus allowing your application to look nice on all platforms.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: