Answer:
Sure. A frame can hold many GUI components.
Two Buttons in a Frame
Let's develop a new program:
- A frame will hold two buttons, one labeled "Red" and the other "Green."
- The
FlowLayoutlayout manager will be used so the buttons will be nicely positioned in the frame. - When the button marked "Red" is clicked, the background will turn red.
- When the button marked "Green" is clicked, the background will turn green.
- There will be one event listener that listens to the clicks from both buttons.
- When the "close button" of the frame is clicked, the application quits.
This is very close to a previous example program. It would be sensible to copy that file and edit it for the new application. However, as a review of these somewhat confusing GUI implementation details, let us start from scratch.
QUESTION 3:
Read the description again and decide on the following:
- How many frames are there?
- What GUI components will it contain?
- What objects generate events?
- What objects receive events?