Java Reference
In-Depth Information
In this interface, the user can:
See the entire input and output simultaneously
Input values for length and width, in any order of preference
Input values that can be corrected after entering them and before clicking
the
Calculate
button
Enter another set of input values and click the
Calculate
button to
obtain the area and perimeter of another rectangle
The interface shown in Figure 6-2 contains various Java GUI components that are labeled
in Figure 6-3.
JLabel
JFrame
6
JTextField
JButton
FIGURE 6-3
Java GUI components
As you can see in Figure 6-3, the white areas used to get the input and show the results
are called
JTextFields
. The labels for these text fields, such as
Enter the length:
, are
called
JLabels
; the buttons
Calculate
and
Exit
are each called a
JButton
. All these
components are placed in a window, called
JFrame
.
Creating this type of user interface is not difficult. Java has done all the work; you merely
need to learn how to use the tools provided by Java to create such an interface. For
example, to create an interface like the one shown in Figures 6-2 and 6-3 that contains
labels, text fields, buttons, and windows, you need to learn how to write the statements
Search WWH ::
Custom Search