Home
Username:
Password:
Java 6 Tutorials

User Interface / The Look & Feel

Subtitles of the Movie

Your Java program is sort of like a chameleon. It will change its look and feel to match the style of other programs on your system. The look is the appearance and the feel refers to the way they behave. The Swing Manager will automatically select the look and feel for you so there's nothing you need to do. Your application will automatically morph to the system on which it's running. For the Solaris or Linux system with GTK2.2 or later installed, Java has a look and feel interface named GTK Plus. If GTK is not installed, Java has a motif look and feel that it uses. IBM's version of UNIX is called AIX and IBM has its own Java look and feel. Also HP's UNIX, HPUX, has its own Java look and feel. Java has the different look and feel interface for the different versions of Windows and Apple Macintosh has its own look and feel for Java. There is one other look and feel. It's the cross-platform look and feel, also known as the Java look and feel. You will also see it referred to as the metal look and feel. It's commonly used as the default and it is the one that you've been seeing in the examples for this course. You can invoke a different look and feel if you wish, but you need to choose from among the ones that are installed on your system and you need to do it at the very beginning of your program before anything is displayed. I have an example that lets you choose from the installed look and feels. You will need to import the UI Manager class, the User Interface Manager. All the work is done in main. Now, every system is a little different, so you will need to get a list of the look and feel classes that are installed and ready to be used. You can pretty well count on there being more than just the default one. This loop prints out the list of class names. It's usually a short list; three or four names. The names are the full-qualified class path names. The get index method is a local method written for this example. All it does is read a single-digit integer from the keyboard. The index it reads is used to choose one of the installed look and feel classes. It is the name of the chosen class that is used to specify the look and feel. This method can throw any one of several different types of exceptions, but if it doesn't, the new look and feel will have been applied. Here's how it looks. As you can see, there are four look and feel options to choose from. The first one is the default. If you make no change, it will be the one that's applied. This interface makes the application look like a standard Windows application. It look like something written in C Plus Plus or Basic. Using another look and feel makes it almost seem like a different program is running. The coloring, font, button, declarations, everything looks different and acts a little different. If you wanted, you could write your program to try to find different looks and feels and use one only if it's present. Next is a lesson about how you can use the toolbars for another approach to the user interface.

Tutorial Information

Course: Java 6
Author: Arthur Griffith
SKU: 33858
ISBN: 1-934743-59-3
Release Date: 2008-02-29
Duration: 7 hrs / 92 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available