How to set the Look and Feel

Every now and then I want to specify the look and feel for a Java swing application. And every time I have to search the net for info on how to do it (some info just never stays in the memory).

I was hoping that the new Netbeans 5.0 IDE was going to implement some sort of helpful tool to set the look and feel for a project, but no. You're still stuck with doing it by hand.

So, to avoid having to search for this information ever again I'll enter it in the notebook.

How it's done

This is and how you set the cross-platform look and feel:

public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(
            UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) { }

    // start your aplication here...
}

Read more


Comment this note:

Your name:
Your email (hidden):
Message:
Enter the validation code :
Private! (visible for webmaster only)

Tobbe 2006-02-23 10:55:13

Thanx alot! Great stuff!