Skip to main content

Section 13.10 Chapter Summary

Subsection 13.10.1 Technical Terms

adapter class lightweight component
callback design listener
content pane model
containment hierarchy model-view-controller (MVC)
controller peer model
event model pluggable look and feel
inner class view
layout manager widget hierarchy

Subsection 13.10.2 Important Points

  • Java provides two sets of Graphical User Interface (GUI) components, the Abstract Windowing Toolkit (AWT), which was part of Java 1.0 and the Swing component set, the GUI part of the Java Foundation Classes (JFC), introduced in JDK 1.1.

  • Unlike their AWT counterparts, Swing components are written entirely in Java. This allows programs written in Swing to have a platform-independent look and feel. There are three built-in look-and-feel packages in Swing: a Windows style, a Unix-like Motif style, and a purely Java Metal style.

  • Swing components are based on the model-view-controller (MVC) architecture, in which the component is divided into three separate objects: how it looks (view), what state it's in (model), and what it does (controller). The view and controller parts are sometimes combined into a single user interface class, which can be changed to create a customized look and feel.

  • AWT components are based on the peer model, in which every AWT component has a peer in the native windowing system. This model is less efficient and more platform dependent than the MVC model.

  • Java's event model is based on event listeners. When a GUI component is created, it is registered with an appropriate event listener, which takes responsibility for handling the component's events.

  • A user interface combines four functions: guidance/information for the user, input, output, and control.

  • Components in a GUI are organized into a containment hierarchy that is rooted at the top-level window. JPanel s and other Container s can be used to organize the components into a hierarchy according to function or some other criterion.

  • The top-level Swing classes—JApplet, JDialog, JFrame, and JWindow—use a content pane as their component container.

  • A GUI should minimize the number of input devices the user needs to manipulate, as well as the complexity the user needs to deal with. Certain forms of redundancy—such as two independent but complete sets of controls—are desirable because they make the interface more flexible and more widely applicable.

  • A layout manager is an object that manages the size and arrangement of the components in a container. The AWT and Swing provide a number of built-in layouts, including flow, border, grid, and box layouts.

  • A radio button is a toggle button that belongs to a group in which only one button from the group may be selected at the same time. A checkbox is a toggle button that always displays its state.

  • A well-designed interface should reduce the chance of user error and should make it as easy as possible to recover from errors when they do occur.

Solutions 13.10.3 Solutions to Self-Study Exercises

13.3 OBJECT-ORIENTED DESIGN: Model-View-Controller Architecture
13.3.2 Self-Study Exercise

13.4 The Java Event Model
13.4.2 Self-Study Exercises

13.5 CASE STUDY: Designing a Basic GUI
13.5.2 GUI Design Critique

Self-Study Exercises

13.6 Containers and Layout Managers
13.6.5 Self-Study Exercises

Exercise 13.6.11. Converter with BorderLayout.

13.7 Checkboxes, Radio Buttons, and Borders
13.7.6 Self-Study Exercise

13.8 Menus and Scroll Panes
13.8.6 Self-Study Exercises

Exercise 13.8.9. No Duplicate Cuts.
Exercise 13.8.10. FileMenu Actions.
You have attempted of activities on this page.