Java Reference
In-Depth Information
setSize(350, 225);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton alpha = new JButton(“Alpha”);
JButton beta = new JButton(“Beta”);
JButton gamma = new JButton(“Gamma”);
JPanel content = new JPanel();
// answer goes here
content.add(alpha);
content.add(beta);
content.add(gamma);
add(content);
pack();
setVisible(true);
}
public static void main(String[] arguments) {
ThreeButtons b3 = new ThreeButtons();
}
}
Which statement should replace // answer goes here to make the frame display all
three buttons side by side?
a. content.setLayout(null);
b. content.setLayout(new FlowLayout());
c. content.setLayout(new GridLayout(3,1));
d. content.setLayout(new BorderLayout());
The answer is available on the topic's website at http://www.java21days.com. Visit the
Day 11 page and click the Certification Practice link.
Exercises
To extend your knowledge of the subjects covered today, try the following exercises:
1. Create a user interface that displays a calendar for a single month, including head-
ings for the seven days of the week and a title of the month across the top.
2. Create an interface that incorporates more than one layout manager.
Where applicable, exercise solutions are offered on the topic's website at http://www.
java21days.com.
 
Search WWH ::




Custom Search