|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Panel
|
+--java.applet.Applet
|
+--TimerBean
This Java Bean allows the user to visually display a "timer" or clock that increments to a specified time and then stops. When the specified time is reached (timeOut) the bean visually displays "TIME OUT". Also the bean gives ways to Start, Stop, Reset the timer and receive notifications of the user's actions.
| Inner classes inherited from class java.applet.Applet |
java.applet.Applet.AccessibleApplet |
| Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
| Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
TimerBean()
|
|
| Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
This method adds a listener to the TimerBean (bean). |
java.awt.Dimension |
getMinimumSize()
This method defines the minimum size that the physical Applet can be. |
java.lang.String |
getTimeOut()
This method returns the current value of the timeOut value. |
void |
init()
The init method loads all the timer images that are needed in the bean. |
void |
paint(java.awt.Graphics g)
The paint method paints the timer clock images on the Applet. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
This method removes a listener to the TimerBean. |
void |
resetTimer(java.awt.event.ActionEvent x)
This method resets the timer to zero. |
void |
run()
This thread increments the time every second until the timeOut value has been reached at which point the "Time Out" image is displayed. |
void |
setTimedOut(boolean status)
This method sets the 'timedOut' flag to true if the time has timed out and false if it has not. |
void |
setTimeOut(java.lang.String s)
This method sets the timeOut variable to a new value. |
void |
startTimer(java.awt.event.ActionEvent x)
This method starts the timer. |
void |
stopTimer(java.awt.event.ActionEvent x)
This method stops the timer. |
void |
updateStatus(java.lang.String s)
This method is called whenever the status of the bean changes. |
| Methods inherited from class java.applet.Applet |
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
| Methods inherited from class java.awt.Panel |
addNotify |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TimerBean()
| Method Detail |
public void init()
PRE: The init method assumes that all of the image files (*.gif) used in this project are located in the project directory.
POST: This method does nothing more than load in all the images and save them to the Image object array for future use in the program.
init in class java.applet.Appletpublic java.awt.Dimension getMinimumSize()
PRE: None.
POST: This method does nothing more than return the Minimum Size Dimension of our Applet.
getMinimumSize in class java.awt.Containerpublic void paint(java.awt.Graphics g)
PRE: This method assumes that the parameter is valid and not equal to null.
POST: The main purpose of this method is to paint the current timer time or paint the "Time Out" image if time has expired. If by chance the Image Object array which was created in the "init" method is empty then a message notifying the user of the problem is printed.
paint in class java.awt.Containerg - Handle to the area on the Applet that will be painted.public void setTimedOut(boolean status)
PRE: This method assumes that the parameter is valid and not equal to null.
POST: This method does nothing more than set the "timedOut" variable equal to the parameter and return.
status - Status of the timer. Whether it has timed out or not.public void setTimeOut(java.lang.String s)
PRE: This method assumes that the parameter is not equal to null. It is assumed that the string is in the following time format: "##:##:##" where # equals a positive numrical digit.
POST: This method does nothing more than set the "timeOut" String variable to the parameter and return.
s - New time that the timer will stop at.public java.lang.String getTimeOut()
PRE: None.
POST: This method does nothing more than return the "timeOut" variable.
public void run()
PRE: This method assumes that the project has implemented "Runnable" and that the system that the project will be running on can handle threads.
POST: This method is the heart and soul of the project. This is were things get done. Anyways, if the thread/timer is not stopped and is enabled then the program gets the Graphics object and paints the current time of the timer or if it is timed out it paints the "Time Out" image. Next the method/thread sleeps for the time period of 1 second and then checks to see if the current timer time is equal to the timeOut value (the time the timer is supposed to stop at). If the timer time and the timeOut values are equal then the Timed Out flags are set and the "Time Out" image is painted. Otherwise the current timer time is incremented by 1. At this point the whole process is repeated.
run in interface java.lang.Runnablepublic void startTimer(java.awt.event.ActionEvent x)
PRE: This method assumes that the ActionEvent parameter is not equal to null and that this method is called only when the user wants to start the timer.
POST: This method starts the timer thread and reset the counter if the "timedOut" flag is set. It also sets the "stopped" flag to false and notifies the "updateStatus" method that the timer has started.
x - Action from the user to start the timer.public void stopTimer(java.awt.event.ActionEvent x)
PRE: This method assumes that it is called only if the user want the timer to be stopped or paused.
POST: This method first of all sets the "stopped" flag to true and notifies the "updateStatus" method that the timer has stopped. Then it gets the Graphic object and paints the current timer time or it paints the "Time Out" image if the timer has timed out.
x - Action from the user to stop the timer.public void resetTimer(java.awt.event.ActionEvent x)
PRE: This method assumes that it is called only when the user wants to reset the counter to zero.
POST: This method first of all sets the "stopped" flag to true and notifies the "updateStatus" method that the timer has been reset. Then the Graphics object it retrieved, the timer is reset to zero, and the initial time is painted on the GUI.
x - Action from the user to reset the timer.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PRE: This method assumes that the parameter is not equal to null and that it represents a program that wants to listen for changes produced by this Timer Bean.
POST: This method does nothing more than add the listener to PropertyChangeSupport list.
addPropertyChangeListener in class java.awt.Componentlistener - This is a handle to another object (bean) that wants to
receive updates from the TimerBean.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PRE: This method assumes that the parameter is not equal to null and that it represents a program that no longer wants to listen for changes produced by this Timer Bean.
POST: This method does nothing more than remove the listener from the PropertyChangeSupport list.
removePropertyChangeListener in class java.awt.Componentlistener - Handle to the object (bean) that no longer wants to listen
to TimerBean updates.public void updateStatus(java.lang.String s)
PRE: This method assumes that the parameter is not equal to null.
POST: This method does nothing more than fire the "firePropertyChange" method letting all listeners of the Timer Bean know that the "status" property has changed. It also provides them with the current and old values.
s - String describing the new status of the bean.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||