Problem

Listener Trade-Offs: Code Simplicity and EfficiencyA GUI displays a 10 by 20 grid of image...

Listener Trade-Offs: Code Simplicity and Efficiency

A GUI displays a 10 by 20 grid of images. Clicking on an image triggers some action. Here are three ways to design the GUI.

a. Use 200 JButton objects with a grid layout. Create a listener to handle button clicks, and register the listener with each button.


b. Use 200 JLabel objects with a grid layout. Register a single mouse listener to check for clicks, and depending on the location of a click, follow the appropriate action.


c. Use no labels or buttons. Draw images on the frame using g.DrawImage(…), where g is a Graphics object. Register a single mouse listener to check for clicks, and depending on the location of a click, follow the appropriate action, and call repaint().

What are the advantages and disadvantages of each method with respect to simplicity and efficiency? Be specific. Consider the number of objects that you define, the number of events that must handled, and the difficulty of implementing the listener methods that handle the events.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 19
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT