Browsing all posts in May, 2009.
The Model-View-Controller Architecture
Swing uses the model-view-controller architecture (MVC) as the fundamental design behind each of its components. Essentially, MVC breaks GUI components into three elements. Each of these elements plays a crucial role in how the component behaves.
Model
The model encompasses the state data for each component. There are different models for different types of components. For [...]
Swing Packages and Classes
Here is a short description of each package in the Swing libraries:
javax.accessibility
Contains classes and interfaces that can be used to allow assistive technologies to interact with Swing components. Assistive technologies cover a broad range of items, from audible text readers to screen magnification. Although the accessibility classes are technically not part of Swing, they [...]
The Swing Text Components
Despite all the complexity and power Swing’s text components provide, it’s still pretty simple to do most things. Now it’s shows each of the six Swing text components, plus an extra JTextArea (to show a different wrapping style) and an extra JEditorPane (to show a different EditorKit).
Here the code:
// TextComponentSampler.java
//
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
import java.awt.*;
[...]
Changing borders on the fly
Here is a short program that creates four labels. Each label draws a bevel border around itself when the mouse pointer enters the component’s region and erases it when the mouse leaves the region. This kind of “rollover” effect has become a popular feature in some applications’ toolbars. Modifying the program to use soft bevel [...]

