Java Swing | Look And Feel  |  Step By Step.
2

In this article we will see how to apply cool and amazing UI in our swing desktop application in java.

For that we will use UIManagener class and setLookAndFeel() method.

Important note : setLookAndFeel() method Throws an exception if newLookAndFeel is non-null and newLookAndFeel.isSupportedLookAndFeel() returns false. For we will surround this statement with try-catch block.

  1.    Use of UIManagener class : UIManager manages the current look and feel, the set of available look and feels, PropertyChangeListeners that are notified when the look and feel changes, look and feel defaults, and convenience methods for obtaining various default values.
  2.    Use of setLookAndFeel() method : Sets the current look and feel to newLookAndFeel. If the current look and feel is non-null uninitialize is invoked on it. If newLookAndFeel is non-null, initialize is invoked on it followed by getDefaults. The defaults returned from newLookAndFeel.getDefaults() replace those of the defaults from the previous look and feel. If the newLookAndFeel is null, the look and feel defaults are set to null.
  3.    What is try-catch block : The try statement allows you to define a block of code to be tested for errors while it is being executed. The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.

Apply Look And Feel In Java Swing Desktop Application :

Step 1 : Downalod .jar files :

You can downlaod .jar files by follows below video steps otherwise you can easly download files by clicking below three links
1. flatlaf-demo-2.2.jar
2. flatlaf-2.2.jar
3. flatlaf-intellij-themes-2.2.jar

Step 2 : Apply Look And Feel In Your Java Swing Application :

See this below video for better understand how to apply look and feel in java swing application.