CSE190L Sample Layout Problem handout #22
1. Layout managers. You are to write code that structures the layout managers
for a JFrame. This particular JFrame shows two animations side-by-side and
includes controls for changing the number of periods used for each animation
and controls for making the animations go faster or slower.
In the upper-left corner you should have a button labeled "quit" and in the
upper-right corner you should have a button labeled "reset". Below these
you should have two side-by-side sets of controls each with: a labeled text
field for the number of periods on top of a drawing panel for the animation
on top of two buttons labeled "faster" and "slower". All extra vertical and
horizontal space should go to the two drawing panels. The other
side-by-side controls should stay at their preferred size, centered
horizontally on their half of the frame. The quit and reset buttons should
always stay in the corners and should always appear at their preferred
sizes. You may assume that the frame has enough horizontal space to display
the faster/slower buttons side-by-side and to display the labeled text
fields.
Notice that the labeled text fields for periods appear against a white
background. Also notice that there is a black line separating the left and
right sides. This line is one pixel wide. As in the diagram above, it
should appear only between the side-by-side elements, not between the quit
and reset buttons.
Assume that the following variables have been defined:
quit the quit button
reset the reset button
periods1/periods2 the side-by-side text fields for "periods"
panel1/panel2 the side-by-side drawing panels
faster1/slower1 the left-hand faster/slower buttons
faster2/slower2 the right-hand faster/slower buttons
Write code below that would be included in the JFrame's constructor to lay
out these components properly. Note that you only have to do the layout.
You don't have to create the objects, attach listeners or otherwise solve
the overall problem. The only objects you should create are the layout
containers, the layout managers and the labels used for the text fields.
You are allowed to define private methods if you want to. Write your
solution to the layout problem below.