Page 768 - Introduction to Programming with Java: A Problem Solving Approach
P. 768

                734 Chapter 17 GUI Programming—Component Layout, Additional GUI Components
 Intended layout: Actual layout:
   Skills (check all that apply):
 Java Sun certified
     help-desk experience
   able to make good coffee
       Community standing:
   law-abiding citizen
 violent criminal
  Salary requirements:
   $20,000-$59,000
    Submit
 Skills (check all that apply):
 Java Sun certified
     help-desk experience
   able to make good coffee
   Community standing:
 law-abiding citizen
 violent criminal
  Salary requirements:
  $20,000-$59,000
  Submit
    Apago PDF Enhancer
Figure 17.18 Intended versus actual layouts with 13-row by 1-column GridLayout scheme
note how the Submit button is slightly taller than the other components. The Submit button’s added height provides a visual cue for the button’s importance. To accommodate the button being taller than the other components, use a BorderLayout manager. Add the button panel to the south region and add all the other components to the center region. Actually, since the center region allows for only one component, you need to add the components to a GridLayout panel and then add the GridLayout panel to the center region.
Document Difficult Code
The JobApplication program’s layout design is rather complicated and somewhat non-intuitive. If you ever write complicated and non-intuitive code, you should document it with detailed comments. If you don’t, then someone (maybe you) might waste time later in trying to figure it out. See all the comments for the panel declarations in Figure 17.17b. Those comments help to clarify the layout-design code.
17.16 More Swing Components
In this chapter and the previous chapter, you’ve learned quite a bit about the Swing library. Enough to get up and running for most basic GUI needs. If you decide you want to know more, refer to Sun’s Java API Web site. In particular, refer to this Web page within Sun’s Java API Web site:
 http://java.sun.com/docs/books/tutorial/uiswing/components/componentlist.html





































































   766   767   768   769   770