Java is another Animal II: Selecting the Look and Feel

Writing Java Swing Applications makes it comfortable to have complex and reliable GUI programming. But like always: when you have a GUI you may want to have another look and feel.

One of the most interesting Java Swing functionalities is the possibility to change the Look and Feel. Like I showed in the former tutorial the change of the look and Feel can be done line this:

Setting this Code to your Public Static Void Main before building the GUI itself selects NIMBUS look and Feel. Nimbus is a modern looking look and feel for Swing. There are also another selectable Options like you can see for example on this Oracle Page: How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel).

But also Third Party Look and Feels are available. Let’s take a look on my favorite one: FlatLaf. While you can download FlatLaf at the JFormdesigner Page here: FlatLaf - Flat Look and Feel | FormDev you can install it in a really simple wise. So lets do it.

We generate at first a small GUI Project with simple UI Elements on it, like this:

It’s looking so with the Nimbus Look and Feel. Now we want to get all the FlatLaf look and Feels from the Formdev Site. First get the latest jar file of it, when writeing this tutorial it was FlatLaf 1.2. After downloading the Jar File.

When downloaded you open the Project Settings in IntelliJIdea Project and select Libraries. There you click on the small + and select Java:

The System asks you to select the Library, in this case it is the jar File we downloaded:

and press okay. The IDE asks now to which Module it shall add it. The Module is named like your Program, in this case untitled6:
Press on OK to accept it.

The IDE now added it. Press on OK to store this Settings. The IDE will add it to your list of external Libraries:

Now we can use this Library in our Programs. While FlatLaf is a nice “Animal” you can install a Look and Feel from the FlatLaf Look and Feels with a simple Install order instead of our UI Selector we used until now so first we clean our Publis Static Void Main:
and set directly to the beginning of the Method:
Pressing now the green run Arrow results in:
Changing FlatLightLaf() to FlatIntelliJLaf() brings this result:
And FlatDarculaLaf() brings this result:
To see which Themes are in the Jar you can download the Demo and start it from command Line with java -jar name_of_the_jar.jar. Have fun.