Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

12.2 Steps to Code Event Delegation 1. import java.awt.event.* 2. implements the appropriate interface from the defined class Eg: implements ActionListener 3. Register GUI component

image text in transcribedimage text in transcribedimage text in transcribed

12.2 Steps to Code Event Delegation 1. import java.awt.event.* 2. implements the appropriate interface from the defined class Eg: implements ActionListener 3. Register GUI component to the appropriate listener - Eg: button.addActionListener(this); 4. Implements interface method - Eg : public void actionPerformed (ActionEvent e) {...} Page 141 12 EVENT HANDLING 12.3 Example of Event Handling The following code demonstrates a GUI to display "Java is fun and easy" when the user clicks on Press Me button as shown in Figure 12-1. import java.awt.BorderLayout; import java.awt.event. ActionEvent; import java.awt.event. ActionListener; Exercise 1 1. Using Point of Sales GUI developed from Lab 9 (refer to Figure 12-2), code the following requirements. Point of Sales OX Crunchy Combo 1 - RM 19.70 O Crunchy Combo 2 - RM 26.90 O Hot Variety Box - RM 28.28 Hot Power Meal 1 - RM 22.90 Hot Power Meal 2 - RM 53.90 Select Item : Quantity quantity: Payment Method: Visa Credit card number: DONE! Figure 12-2: GUI of Point of Sales a. User can select only 1 item at one time. b. The quantity should be numbers only. c. Credit card number should be number only. d. Point of Sales will calculate the amount of sales when the user clicks Done. Point of Sales displays an output as shown in Figure 12-3. f. The text area is not editable. e 12 EVENT HANDLING Point of Sales Crunchy Combo 1 - RM 19.70 O Crunchy Combo 2 - RM 26.90 Hot Variety Box - RM 28.28 O Hot Power Meal 1 - RM 22.90 Hot Power Meal 2 - RM 53.90 Select Item: Quantity quantity : 5 Payment Method: Master Credit card number: 345665-4545-0867 DONE! Selected Item Price Per Unit: Hot Power Meal 1 - RM 22.90 Quantity: 5 The amount is RM 114.5 charged to Master 345665-4545-0867 Figure 12-3: Point of Sales with output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago