Look and Feel

From ENIGMA
Jump to navigation Jump to search
Model View and Controller

The Java Swing GUI framework uses a pluggable UI layer by following the model view controller architecture. These UI layers are referred to as the look and feel. The idea behind MVC is that for each component there is a model that holds the actual data and can be used with multiple views. The controller is where input is entered to the program and communicates with the view and data model layer. So we can replace a view of a list and interact with the same data in different ways while using the exact same underlying representation of the data. LateralGM is one program that uses Swing for its GUI presentation layer and it allows you to change the look and feel in the appearance tab of the preferences frame which is found under the file menu.

Customization

The experimental Calico Look and Feel for LateralGM.

It is extremely easy to customize the existing look and feels and to create new ones. The basic look and feels use UI properties that configure the background and foreground colors of controls, text fonts, and other component defaults. The most basic look and feel in Swing is known as the basic look and feel. Each component, such as a label or text control, will be given an equivalent UI component, in the case of a label this will be LabelUI or ButtonUI for a button. The UI component delegate is responsible for painting the control and usually makes use of the default UI properties for the colors, fonts, and basic settings.

From the basic look and feel, the native look and feels such as Windows Classic or GTK+ are derived. They add additional operating system specific component rendering, such as the inclusion of system fonts and colors for active and inactive window titles and selection highlights. Because of this, these look and feels may not respect the UI properties or make any use of them. Some look and feels may also disable the native window decorations, which are the native window borders, and replace them with a cross-platform consistent frame border. This is the case with the Swing, Metal, and Nimbus look and feels. Though some of these look and feels may cover the task bar when the frame is maximized, which is sometimes undesirable.

There are many third party providers of Swing look and feels, including Synthetica, but many are proprietary. There is also the free and open source Web Look and Feel derived from the basic look and feel that can be found on GitHub. It is also possible to create a custom look and feel yourself because of the modular design of the look and feel system, however this can be a difficult task and is much easier when starting with an existing look and feel. A good example of a custom look and feel is Calico Look and Feel which is derived from Metal and can be found on GitHub.

See Also