
Topics
-
Threads including the Main Thread (Model), the Paint Thread (View), and the Event Handler
Thread (Controller).
-
In large programs, data is usually stored in classes
specifically designed to hold the data, without regard how that data is
presented on the screen, or how the user interacts with the program. These
classes are the Model.
-
In large programs, the display of data on the screen is
handled by specialized classes. This is the View. This concept
co-exists with the concept that each object should paint itself on the
screen. Usually the view is the controlling class that tells each object
to paint themselves.
-
The Controller handles user interaction. In Java, the
Controller is implemented by
Listeners and listener functions.
-
Code in three places:
-
implements _______Listener
-
add_____Listener(this)
-
coding of required methods as specified in the _____Listener's Interface.
-
Concept of an Interface -- conceptually the mirror-image of Inheritance.
In Inheritance you use functions you never wrote. In Interfaces, you must
implement the Interface by writing all the functions in the Interface, which are
then called automatically. You write functions that you never call!
-
Using the documentation for Interfaces to find which methods need to be
written
-
getSource() method in EventObject lets you find out which Component caused the
Event
-
The AWTEvent inheritance tree, as seen in the Sun Java
Documentation
-
ActionListener, ItemListener, MouseListener,
MouseMotionListener, FocusListener and TextListener are the most important.
-
Stay away from the KeyListener. Students tend to want
to use it, but it requires that you then write all the code to handle each
keystroke. Usually there are much easier ways of doing what you might want
to do with a KeyListener!
In-Class Lab (2
points shared with January 28th)
Add the Left and Right Buttons, as seen on page 171 of the
text, to the PlayBalloon Applet, and make them work properly. Also, add
the private float calcArea() method, as seen on page 152 of the text, to the
Balloon class. Have the Balloon print its area under itself inside public
void display(Graphics g).
Readings
Chapter 10. This is a short, but very important
chapter. Read everything carefully.