This homework is meant to give you practice with selecting appropriate widgets
for a problem and with selecting and using Java layout managers.
- For each of the following questions answer true or false:
- __________ Experts tend to rely more heavily on recognition
- __________ Menus should be designed so that they contain many
items, thus minimizing the number of required levels
in a menu hierarchy
- __________ You can use a flow layout manager to vertically stack
- __________ In a grid layout manager, all columns must have the
same width and all rows must have the same height.
- __________ Sliders are useful for entering bounded, continuous
data, such as real numbers.
- __________ Check boxes allow you to enter a set of mutually
- Each of the following questions asks you to collect some type
of data or provide some type of operation to the user. For
each question, select the most appropriate widget to use.
You should select each answer from the following list of widgets:
- radio boxes
- check boxes
- command buttons
- text field
- ________________ You want the user to enter a credit card
- ________________ You want the user to select a university status
from the choices of Professor, Student,
Administrator, and Secretary. A user is
allowed to selecct multiple status's.
- ________________ You want the user to select an FM radio
station in an internet radio application.
- ________________ You want the user to select their county of
residence in Tennessee
- ________________ You want the user to enter the volume of a
speaker that should ranger between 0 and 20.
- The following code uses the Box component, which is a
Java container that implements the Box layout manager. Sketch
a picture of the window layout that will be created by this code.
You may assume that the buttons are JButtons whose labels are the
same as the variable names representing the buttons. You may
draw the buttons as rectangles with their respective labels.
Box b1 = Box.createVerticalBox();
Box b2 = Box.createHorizontalBox();
- I have created a layout program that mimics part of the flight
dialog box used by Travelocity's
Play with the application by resizing the window to see how the layout
Your assignment for this problem is to complete the file named
travelocity.java so that it mimics my layout.
declares and allocates all the widgets that you need. You simply need to
add panels, boxes, and layout managers. You can find travelocity.java
- I used the GridBagLayout manager to group and
handle the six items associated with Departure and Return
(the two labels, the two textfields, and the two combo boxes).
There is a 20 pixel separation between the combo boxes and the
- I used the GridLayout manager to handle the four items associated
with the From and To textboxes (the two labels and the two textfields).
- I used a BorderLayout to position the Departure/Return and
"Exact dates" groups with respect to one another.
- I used BoxLayouts everywhere else.
What To Submit
- Put your answers for questions 1-3 into a file named either
answers.txt if you are using a text editor or
answers.pdf if you are using a word processor.
- Put your source and class files for question 4 into an
executable jar file named travelocity.jar.
- Submit your two files using the appropriate submit script.