(11 points)
On the next page, sketch the window that is drawn by the following code. Where there are
fixed distances between objects, indicate what those fixed distances are.
Assume that the window being drawn is much wider and taller than the
buttons that it contains (i.e., I want you to show me that you know what
Horizontal and VerticalGlue do when the window is bigger than the
elements it is displaying).
JButton b1 = new JButton("Button1");
JButton b2 = new JButton("Button2");
JButton b3 = new JButton("Button3");
JButton b4 = new JButton("Button4");
JButton b5 = new JButton("Button5");
// set layout for the top level container
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
Box buttonGroup1 = Box.createHorizontalBox();
Box buttonGroup2 = Box.createHorizontalBox();
Box buttonGroup3 = Box.createHorizontalBox();
buttonGroup1.add(Box.createHorizontalGlue());
buttonGroup1.add(b1);
buttonGroup1.add(Box.createHorizontalGlue());
buttonGroup1.add(b2);
buttonGroup1.add(Box.createHorizontalGlue());
buttonGroup1.add(b3);
buttonGroup1.add(Box.createHorizontalGlue());
buttonGroup2.add(Box.createHorizontalGlue());
buttonGroup2.add(b4);
buttonGroup2.add(Box.createHorizontalGlue());
buttonGroup3.add(Box.createRigidArea(new Dimension(20, 0)));
buttonGroup3.add(b5);
buttonGroup3.add(Box.createHorizontalGlue());
add(Box.createRigidArea(new Dimension(0,5)));
add(buttonGroup1);
add(Box.createRigidArea(new Dimension(0,5)));
add(buttonGroup2);
add(Box.createVerticalGlue());
add(buttonGroup3);
add(Box.createVerticalGlue());