Picture of the Relations
Perhaps a picture is needed. Clouds represent class definitions, and rectangles
represent objects.
The interface is a dotted rectangle (becuase it is neither a class nor an object.)
The main() method is static, also represented with a dotted rectangle.
Look back at the
example program
as you study the diagram.
- The class buttonDemo extends the class Frame.
- The main() method is static, so is not part of any object.
- Main contains two reference variables:
- frm, which refers to a buttonDemo object, and
- wquit, which refers to a WindowQuitter object
- There is a single buttonDemo object, which will be the frame the users sees
on the monitor screen.
- There is a single Button object (which will appear inside of the frame.)
- Events from the button are sent to the buttonDemo object.
- The buttonDemo object was registered as a listener for Action Events.
- The buttonDemo class implements ActionListener.
- Events from the frame are sent to the WindowQuitter object.
- The WindowQuitter object was registered as a listener for Window Events.
- The WindowQuitter class extends WindowAdapter.
Don't be discouraged if this is less than perfectly clear!
It usually takes some time to get all of these relationships straight.
A bit more practice would not hurt, either.
|