Page 775 - Introduction to Programming with Java: A Problem Solving Approach
P. 775
(b) Specify the changes you would make to the above code to produce this output:
6. [after §17.5] If a JButton component is directly added to a GridLayout cell, it expands so that it completely fills the size of its cell. (T / F)
7. [after §17.5] Given the following code fragment, draw a picture that illustrates the buttons’ positions within the program’s window.
setLayout(new GridLayout(0, 3));
add(new JButton("1"));
add(new JButton("2"));
add(new JButton("3"));
add(new JButton("4"));
add(new JButton("5"));
add(new JButtoAn(p"6a")g);o PDF Enhancer add(new JButton("7"));
8. [after §17.9] What kind of container should you put into an individual grid layout cell or an individual border layout region to allow that cell or region to contain more than one component?
9. [after §17.11] Suppose you’re given a window with two JTextArea components, named msg1 and msg2, and a JButton component. When clicked, the button swaps the contents of the two text areas. Provide the code that performs the swap operation. More specifically, provide the code that goes inside the below actionPerformed method:
private class Listener implements ActionListener
{
}
public void actionPerformed(ActionEvent e)
{
}
...
10. [after §17.12] Provide a statement that creates a check box named bold. The check box should be unselected, and it should have a “boldface type” label.
11. [after §17.12] How can your code determine whether a check box is selected or not?
12. [after §17.13] Provide a createContents method for a program that displays this window:
Exercises 741