Setting the look and feel
AdministratorFrame constructor, immediately after the call to super():
// Set to native look & feel
try {
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
// If unable just carry on with default look & feel
}
UIManageris a class that manages look & feels. It contains the static methodsetLookAndFeel()that takes as aStringargument the name of the class that controls the look & feel you want- The argument being passed is the
Stringreturned by another static method ofUIManagercalledgetSystemLookAndFeelClassName(). This returns the name of the class for the platform on which it is executing, if there is one, or the default look & feel otherwise - The
setLookAndFeel()method can potentially throw one of several different exceptions (see the Javadoc API), so for simplicity the code above catches the superclass of all of these, beingException - If an exception is thrown, it is hoped that the display will still render using the default look & feel, so the exception details are sent to the console and the application will continue anyway
Here is how it looks on the Windows platform:
The only major topic left to cover is that of storing the data in a file or database, which is known as persistence. This will be covered in the next series of lessons.
Comments