|
|
|
|||
|
Swing Features and ConceptsThis lesson introduces Swing's features and explains all the concepts you need to be able to use Swing components effectively. At the end of this lesson we dissect a Swing program, as a means of reviewing everything you've learned.Swing Components and the Containment HierarchySwing provides many standard GUI components such as buttons, lists, menus, and text areas, which you combine to create your program's GUI. It also includes containers such as windows and tool bars. Layout ManagementContainers use layout managers to determine the size and position of the components they contain. Borders affect the layout of Swing GUIs by making Swing components larger. You can also use invisible components to affect layout. Event HandlingEvent handling is how programs respond to external events, such as the user pressing a mouse button. Swing programs perform all their painting and event handling in the event-dispatching thread. PaintingPainting means drawing the component on-screen. Although it's easy to customize a component's painting, most programs don't do anything more complicated than customizing a component's border. Threads and Swing
If you do something to a visible component
that might depend on or affect its state,
then you need to do it from the event-dispatching thread.
This isn't an issue for many simple programs,
which generally refer to components
only in event-handling code.
However, other programs
need to use the
More Swing Features and Concepts
Swing offers many features,
many of which rely on support provided by
the
The Anatomy of a Swing-Based Program
A sample Swing application named
| |||
|