13.14 Summary

The major GUI controls available in Java are Button, Checkbox (which can create regular checkboxes or radio buttons), Choice, List, TextField, TextArea, Label, Scrollbar (used for scrolling and for selecting values), and PopupMenu. This is in addition to the bordered and borderless windows, dialog boxes, and file dialogs covered in Chapter 11, "Windows." In addition, two new components were created: ImageButton and Slider. The first illustrated how to build new components from scratch, while the second showed how to combine existing widgets into a composite interface control. To use built-in or custom GUI components, there are two things you need to know: how to create them with the look you want, and how to process the events that occur when the user interacts with them. In most cases, the main look is specified in the interface element's constructor, but some elements (Choice, List, PopupMenu) are created empty then filled later. Action events are perhaps the most important type of event that applies to GUI elements, but item selection events, keyboard events, text events (Java 1.1 only), and scrolling events are important as well.

Now, perhaps you wondered how Java was able to monitor and generate events for you. How do they do this while your code is performing other tasks? The answer is that Java is multithreaded; different lightweight processes can handle different tasks concurrently. Multithreading makes it easy for Java to monitor GUI events, and it can simplify many of your tasks as well. In some cases, it can also significantly speed up your application. That's the topic of the next chapter.


Return to Chapter 13 table of contents.