All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class SpeedSwitch.SpeedSwitch

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----SpeedSwitch.SpeedSwitch

public class SpeedSwitch
extends Applet
implements Runnable, MouseListener

Constructor Index

 o SpeedSwitch()

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed.
 o drawSwitchIfLoaded(Graphics)
If all the images have loaded without error, get the state property and render the appropriate image.
 o drawSwitchOnEvent(int, int)
Intended to be called on a mouse click.
 o getState()
Getter for state.
 o init()
Load the images for the switch, and add them to a MediaTracker object.
 o mouseClicked(MouseEvent)
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mousePressed(MouseEvent)
 o mouseReleased(MouseEvent)
Call drawSwitchOnEvent to set the state.
 o paint(Graphics)
Just call drawSwitchIfLoaded(g)
 o removePropertyChangeListener(PropertyChangeListener)
Remove this PropertyChangeListener from the JellyBeans internal list.
 o run()
Keep repainting the image.
 o setState(String)
Setter for state.
 o start()
 o stop()
 o update(Graphics)
Call paint(g) without redrawing first.

Constructors

 o SpeedSwitch
 public SpeedSwitch()

Methods

 o init
 public void init()
Load the images for the switch, and add them to a MediaTracker object.

Overrides:
init in class Applet
 o start
 public void start()
Overrides:
start in class Applet
 o paint
 public void paint(Graphics g)
Just call drawSwitchIfLoaded(g)

Overrides:
paint in class Container
 o drawSwitchIfLoaded
 public void drawSwitchIfLoaded(Graphics g) throws Exception
If all the images have loaded without error, get the state property and render the appropriate image.

Throws: if
an error in loading any image.
 o drawSwitchOnEvent
 public void drawSwitchOnEvent(int xPos,
                               int yPos)
Intended to be called on a mouse click. Sets the state depending on the position of the click.

Parameters:
xPos — the x coordinate of the click.
yPos — the y coordinate of the click.
 o run
 public void run()
Keep repainting the image.

 o stop
 public void stop()
Overrides:
stop in class Applet
 o update
 public void update(Graphics g)
Call paint(g) without redrawing first.

Overrides:
update in class Container
 o mouseClicked
 public void mouseClicked(MouseEvent e)
 o mousePressed
 public void mousePressed(MouseEvent e)
 o mouseReleased
 public void mouseReleased(MouseEvent e)
Call drawSwitchOnEvent to set the state.

 o mouseEntered
 public void mouseEntered(MouseEvent e)
 o mouseExited
 public void mouseExited(MouseEvent e)
 o getState
 public String getState()
Getter for state.

 o setState
 public void setState(String newState)
Setter for state. Fires the property change for the information of bean building tools.

Parameters:
newState — the new state of the speed switch.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener l)
The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed. The PropertyListener object is addded to a list of PropertyChangeListeners managed by the JellyBean, it can be removed with removePropertyChangeListener. Note: the JavaBeans specification does not require PropertyChangeListeners to run in any particular order.

Parameters:
l — the PropertyChangeListener
See Also:
removePropertyChangeListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
Remove this PropertyChangeListener from the JellyBeans internal list. If the PropertyChangeListener isn't on the list, silently do nothing.

Parameters:
l — the PropertyChangeListener
See Also:
addPropertyChangeListener

All Packages  Class Hierarchy  This Package  Previous  Next  Index