latest revision Jan 30 /, 2001
Run the code at the end of the Intro to Swing note. Give it a the code
careful read.
Experiment with changing the code. Be methodical change one thing at
a time. If it
causes the program to stop working restore the old value. Change the
the type and
number of components. Change the names of the labels button and fields.
Try changing
the layout managers and the arguments to the layouts and observe the
effects. . You can
use remarks ( // ) to store the old line for
the event you have a problem recovering from
a change you have made.
If this is all going well, start from scratch and begin a new layout.
Begin adding a different
component to each region of the layout you are using. Then you might
add a couple of
components to a panel which in turn you can add to your layout. Try
adding your panel
to different regions of your layout and observe how the layout managers
effect the
appearance of the contained components. Study the parts of the code
apparatus
that add responds to activating your components. Those code lines will
be the
1) implements ActionsListener,
2) button.addActionListener(this)
3) the method public
void actionPerformed(ActionEvent ae){ ..}
4) the stuff inside
this method which is the response to the component's
activation
Finally, look at the Collector and Classifier
projects and consider how you would layout
these interfaces. At this point don't let what
you know or don't know restrict your concept
of where and how you want your layout to appear.
Assignment
1) Use the modified SwingFrame as a base model to make the following
changes.
2) Add an additional textfield and label enabling the entry of field
called population.
3) Create a new JPanel
4) Set the new JPanel's layout to a grid layout with one row and two
columns.
5) A the already defined JList object to one of the columns.
6) Add a new JTextArea to the second region of the grid layout with
the text "Comments"
passed in to it's constructor.
7) Add the new JPanel you have created to the center region of the
border layout of the
mainframe. (This will replace where the JList once
was located.)