|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--javax.swing.JWindow | +--EggTimer.EggTimer
A visible count-down timer. The hand of the watch makes exactly one complete revolution during the period for which the timer is set. The animation stops when the timer expires, or is stopped, but time continues to accumulate. The timer begins counting down only when it is "started". It can only be started once. After starting, the timer is in the "running" state until the time expires (or until it is stopped). In the running state, the timer can be paused and resumed (as many times as desired). While paused, no time is charged. The timer can be stopped only once; after stopping, no other state changes can happen. The percent time used of a stopped or expired timer is always 1.0. Ticks generate EggTimerChangeEvents. The timer raises an EggTimerRunoutEvent when the time expires. Clients can get some basic information about the timer status. It is NOT necessary for clients to implement the listener interface if they don't care about the event notifications; the visual timer is unaffected.
Nested Class Summary |
Nested classes inherited from class javax.swing.JWindow |
javax.swing.JWindow.AccessibleJWindow |
Nested classes inherited from class java.awt.Window |
java.awt.Window.AccessibleAWTWindow |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
static double |
defaultTimeIntervalInSeconds
Length of time for which the timer runs, in seconds, by default. |
static int |
defaultWindowWidth
|
static java.awt.Color |
windowBackgroundColor
|
Fields inherited from class javax.swing.JWindow |
accessibleContext, rootPane, rootPaneCheckingEnabled |
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 | |
EggTimer()
Create and display an egg timer with a default number of seconds. |
|
EggTimer(double seconds)
Create and display an egg timer with the requested number of seconds before expiring. |
Method Summary | |
void |
addEggTimerListener(EggTimerListener listener)
Add an EggTimerEvent listener |
double |
getElapsedTime()
Answer, how much time has the timer accumulated since being started? |
double |
getOriginallyRequestedTime()
Answer, how much time was originally requested for this timer? |
double |
getPercentUsed()
Answer, what percentage of the requested time has elapsed? |
double |
getTimeRemaining()
Answer the amount of time remaining before expiration. |
boolean |
isPaused()
Answer, is the timer currently paused? |
boolean |
isRunning()
Answer, is the timer running? |
boolean |
isStarted()
Answer, has the timer been started? |
boolean |
isStopped()
Answer, has the timer been stopped? |
static void |
main(java.lang.String[] args)
Just a little test method. |
boolean |
moveBy(int dx,
int dy)
Move the visible timer by the given amount (pixels). |
void |
pauseEggTimer()
Freezes the time; elapsed time won't increase until timer is started again. |
void |
processEvent(java.awt.AWTEvent event)
Override the JCompoment's processEvent method. |
void |
removeEggTimerListener(EggTimerListener listener)
Remove the givien EggTimerListener |
void |
resumeEggTimer()
Resumes an egg timer; elapsed time continues where it left off. |
void |
startEggTimer()
Start the timer. |
void |
stopEggTimer()
Stop an egg timer, forever. |
java.lang.String |
toString()
Returns a String describing the egg timer. |
Methods inherited from class javax.swing.JWindow |
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update, windowInit |
Methods inherited from class java.awt.Window |
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final double defaultTimeIntervalInSeconds
public static int defaultWindowWidth
public static java.awt.Color windowBackgroundColor
Constructor Detail |
public EggTimer()
public EggTimer(double seconds)
Method Detail |
public void startEggTimer()
java.lang.RuntimeException
- if the timer is already running.public void pauseEggTimer()
java.lang.RuntimeException
- if timer is already paused or in some other
unpausible state.public void resumeEggTimer()
java.lang.RuntimeException
- if time was not paused.public void stopEggTimer()
RuntimeExcetpion
- if timer has not be started or is already stopped.public boolean isRunning()
public boolean isPaused()
public boolean isStarted()
public boolean isStopped()
public double getElapsedTime()
public double getPercentUsed()
public double getTimeRemaining()
public double getOriginallyRequestedTime()
public void addEggTimerListener(EggTimerListener listener)
public void removeEggTimerListener(EggTimerListener listener)
public boolean moveBy(int dx, int dy)
public java.lang.String toString()
toString
in class java.awt.Component
public void processEvent(java.awt.AWTEvent event)
processEvent
in class java.awt.Window
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |