Page 773 - Introduction to Programming with Java: A Problem Solving Approach
P. 773
§17.5 GridLayout Manager
9. When you instantiate a GridLayout manager, you should always specify both the number of rows and
the number of columns. (T / F)
10. In a grid layout, all cells are the same size. (T / F)
§17.6 Tic-Tac-Toe Example
11. What happens to the xTurn variable in the Tic-Tac-Toe program if you click the same cell twice?
§17.9 JPanel Class
12. Why are JPanel containers particularly useful with GridLayout and BorderLayout windows (as
opposed to FlowLayout windows)?
§17.10 MathCalculator Program
13. In the MathCalculator program’s createContents method, what’s the purpose of the add(new
JLabel()); statement?
§17.11 JTextArea Component
14. JTextArea components are editable by default. (T / F).
15. JTextArea components employ line wrap by default. (T / F).
§17.12 JCheckBox Component
16. What happens if you click a check box that’s already selected?
17. Provide a statement that creates a check box named attendance. The check box should be pre-selected,
and it should have an “I will attend” label.
§17.13 JRadioButton CoAmpoanegnto PDF Enhancer
18. What happens if you click a radio button that is already selected?
19. What happens if you click an initially unselected radio button that is a member of a RadioGroup?
§17.14 JComboBox Component
20. How are combo boxes and radio button groups similar?
21. What two methods can be called to determine the current selection for a combo box?
§17.15 Job Application Example
22. The JobApplication program contains the following code fragment. What happens to the program if the
code fragment is omitted?
radioGroup = new ButtonGroup();
radioGroup.add(goodCitizen);
radioGroup.add(criminal);
23. Provide a statement that adds a 20-pixel blank margin to a JPanel container named panel.
§17.16 More Swing Components
24. Provide a JSlider constructor call where the minimum value is 0, the maximum value is 50, and the
initial value is 10. Hint: Look up the answer on Sun’s Java API Web site.
Exercises
1. [after §17.2] What is the default layout manager for a JFrame window?
2. [after §17.3] With a FlowLayout manager, a button component expands so that it completely fills the size of the region in which it is placed. (T / F)
Exercises 739