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.
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.