Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^396) | Event-Driven Input and Output
User enters values in fields. JVM copies
values into corresponding objects in the
application.
Clicking the Done button fires
the event that calls the event
handler in the listener. The event
handler processes the values in
the objects referenced by the
field variables and resets the
values in the fields.
Payroll
hoursField
payRateField
empNumField
Event Handler
Process data
Reset values in fields
Return to program
Create and display frame
Figure 8.7 Data Entry Process


8.5 Creating a Data Entry Field


Creating a data entry field in Java is very similar to creating a label. The essential steps are
the same, with only minor differences:

1.Declare a variable of the appropriate field class.
2.Instantiate an object of the class.
3.Add the object to the content pane using the addmethod.
Free download pdf