Download CHAP10 - Academic Web Pages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
The User Interface
Chapter Ten
 Text chapter begins with the display
resulting from “running” Balloon.class

A circle with four buttons: Grow, Shrink, Left,
Right
• For the complete text of source program see text or
web site.
An Object Oriented Program:
Model - An application of interest to user…
View - the display
Controller (position/size with Balloon)
Another example
Model
View
0..
100
Speedometer
You
Control
Car
engine
Gas
Pedal
Diagram From Text
Browser
Or Applet
Viewer
User
Object/Model
Interface
Application
Buttons,
check
boxes etc..
Controller
1. User causes event via mouse click (in
Balloon) could be other GUI
2. Browser/Appletviewer (which ever used)
detects event
3. “ “ B/A invokes method to handle event
4. Programmer (YOU) provide method(s) that
respond to user chosen event
5. Action Performed…
event handler invokes appropriate method
6. Method within object changes data within
model
7. Event handler invokes method repaint to
cause image to be redrawn (each time user
causes an event) ie. Clicks a “Balloon”
button
Remember the balloon is just a circle (drawoval)
Some excellent diagrams pages
176-179 follow along until you
feel you understand
BUT ask if you have any
questions
 Browser detects mouse click(s) Java knows
where mouse is/what to do: You don’t have
to worry
 An ActionListener event handler takes over
next
 repaint ( ) (Java takes care of this
 paint( ) You write, Redraw balloon, calls
drawOval with the new User supplied data