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