This section shows how to set different look and feel for your Swing Application.This section shows how to set different look and feel for your Swing Application.
This section shows how to set different look and feel for your Swing Application. The look and feel feature of Java Swing provides more interactivity of the frame for user application. Swing allows to change the Look and Feel of the application on the fly.
In this section, one program has been given to illustrate this feature. This program displays a text area with three command buttons on the frame. Every button labeled with a unique look and feel name. When you click on the specific button, look of the frame will be changed according to the specified look and feel which name is mentioned on the button and the class name of the applied look and feel is shown in the text are.
Screen shots for the result of the given program are given below:
When you run the program:
This frame shows the "Metal" look and feel
when you click on the "Metal" button.
This frame shows the "Motif" look and feel
when you click on the "CDE/Motif" button.
This frame shows the "Window" look and feel
when you click on the "Window" button.
This program helps you for how to get the look and feel for the frame and set it to the specified frame using some following methods and APIs are given as follows:
This is the nested class of UIManager class. The object of this class returns the information about the installed look and feels with the available software development kit. This class creates the instance using the getInstalledLookAndFeels() method of the UIManager class.
This method returns the brief name of the specified look and feel. For example, name of the "javax.swing.plaf.metal.MetalLookAndFeel" look and feel is simply "Metal".
Above method returns the class name for the look and feel of the frame. For example, class name of the "Metal" look and feel is "javax.swing.plaf.metal.MetalLookAndFeel" which is used to set the look and feel.
Above method sets the looks of the frame by the specified look and feel class name i.e. passed through the method as a parameter.
Above method update the each and every node of the frame automatically with the changed look and feel.
Here is the code of the program: