31.15. Chapter Summary

 
[Page 962 ( continued )]

Programming Exercises

Section 28.3 Layout Managers

28.1* ( Demonstrating FlowLayout properties ) Create a program that enables the user to set the properties of a FlowLayout manager dynamically, as shown in Figure 28.30. The FlowLayout manager is used to place fifteen components in a panel. You can set the alignment , hgap , and vgap properties of the FlowLayout dynamically.
[Page 963]
Figure 28.30. The program enables you to set the properties of a FlowLayout manager dynamically.

28.2* ( Demonstrating GridLayout properties ) Create a program that enables the user to set the properties of a GridLayout manager dynamically, as shown in Figure 28.31. The GridLayout manager is used to place fifteen components in a panel. You can set the rows , columns , hgap , and vgap properties of the GridLayout dynamically.
Figure 28.31. The program enables you to set the properties of a GridLayout manager dynamically.


28.3* ( Demonstrating BorderLayout properties ) Create a program that enables the user to set the properties of a BorderLayout manager dynamically, as shown in Figure 28.32. The BorderLayout manager is used to place five components in a panel. You can set the hgap and vgap properties of the BorderLayout dynamically.
Figure 28.32. The program enables you to set the properties of a BorderLayout manager dynamically.



[Page 964]
28.4* ( Using CardLayout ) Write an applet that does arithmetic on integers and rationals. The program uses two panels in a CardLayout manager, one for integer arithmetic and the other for rational arithmetic.

The program provides a combo box with two items Integer and Rational. When the user chooses the Integer item, the integer panel is activated. When the user chooses the rational item, the rational panel is activated (see Figure 28.33).

Figure 28.33. CardLayout is used to select panels that perform integer operations and rational number operations.

28.5* ( Using GridBagLayout ) Use GridBagLayout to lay out a calculator, as shown in Figure 16.21(a).

Sections 28.4 “28.8

28.6* ( Using tabbed panes ) Modify Listing 28.10, DisplayFigure.java, to add a panel of radio buttons for specifying the tab placement of the tabbed pane, as shown in Figure 28.34.
Figure 28.34. The radio buttons let you choose the tab placement of the tabbed pane.

28.7* ( Using tabbed pane ) Rewrite Exercise 28.4 using tabbed panes instead of CardLayout (see Figure 28.35).
Figure 28.35. A tabbed pane is used to select panels that perform integer operations and rational number operations.

28.8* ( Using JSplitPane ) Create a program that displays four figures in split panes, as shown in Figure 28.36. Use the FigurePanel class defined in §13.7, "Case Study: The FigurePanel Class."
[Page 965]
Figure 28.36. Four figures are displayed in split panes.


28.9* ( Demonstrating JSplitPane properties ) Create a program that enables the user to set the properties of a split pane dynamically, as shown in Figure 28.37.
Figure 28.37. The program enables you to set the properties of a split pane dynamically.

 


[Page 966]
 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net