Java Reference
In-Depth Information
25.5 Tip Calculator App—Introduction to Event
Handling
The Tip Calculator app (Fig. 25.9(a)) calculates and displays a restaurant bill tip and total.
By default, the app calculates the total with a 15% tip. You can specify a tip percentage
from 0% to 30% by moving the Slider thumb —this updates the tip percentage
(Fig. 25.9(b) and (c)). In this section, you'll build a Tip Calculator app using several JavaFX
components and learn how to respond to user interactions with the GUI.
a) Initial Tip Calculator GUI
Title bar
User enters bill amount in this
TextField
Current tip percentage
is displayed in this Label
Move the Slider thumb to
change the tip percentage
b) GUI after user enters the amount 34.56
and clicks the Calculate Button
User clicks the Calculate
Button to display the tip
and total
c) GUI after user moves the Slider 's thumb to change the tip
percentage to 20% then clicks the Calculate Button
Updated tip percentage
after user moved the
Slider 's thumb
Fig. 25.9 | Entering the bill amount and calculating the tip.
 
 
Search WWH ::




Custom Search