public class JAnalogClock extends JPanel implements Runnable
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JAnalogClock()
Default constructor to set the time to whenever the class is instantiated
|
JAnalogClock(Date InDate)
Constructor to set the clock to a certain time
|
JAnalogClock(int hour,
int minute,
int second)
Constructor to set the clock to a certain time
|
Modifier and Type | Method and Description |
---|---|
Color |
getBackgroundColor()
Retrieves the background color
|
int |
getHour()
Retrieves the current hour the clock is running at or is displaying.
|
Color |
getHourHandColor()
Retrieves the hour hand color
|
int |
getHourOffset()
Retrieves the Hour offset value
|
Color |
getHoursDotColor()
Retrieves the hours dot color
|
Color |
getMinuteHandColor()
Retrieves the minute hand color
|
int |
getMinutes()
Retrieves the current minute the clock is running at.
|
Color |
getMinutesDotColor()
Retrieves the Minutes dot color
|
int |
getMinutesOffset()
Retrieves the Minute offset value
|
int |
getRefreshInterval()
Retrieves the refresh interval
|
Color |
getSecondHandColor()
Retrieves the second hand color
|
int |
getSeconds()
Retrieves the current second the clock is running at.
|
int |
getSecondsOffset()
Retrieves the Seconds offset value
|
Date |
getTime()
Gets the Date/Time of the clock
|
boolean |
isAutoUpdateToolTipText()
Returns whether the auto update tooltip value is set to true or not.
|
boolean |
isFocusTraversable()
Returns whether the clock can be traversed with the TAB key.
|
boolean |
isRunning()
returns true if the clock is in run mode [start() called] or false
if the clock is not running [stop() called].
|
void |
paint(Graphics g)
Called by the system to repaint the clock when needed.
|
void |
run()
Method that is called by
start to create the thread. |
void |
setAutoUpdateToolTipText(boolean autoUpdateToolTipText)
Sepcifies whether the control should update the tooltip as the clock runs.
|
void |
setBackgroundColor(Color c)
Change the background color of the clock.
|
void |
setHour(int value)
Sets the hour to be shown on the clock.
|
void |
setHourHandColor(Color c)
Change the hour hand color of the clock.
|
void |
setHourOffset(int value)
Changes the number of hours to offset the clock by.
|
void |
setHoursDotColor(Color c)
Change the hours dot color of the clock.
|
void |
setMinuteHandColor(Color c)
Change the minute hand color of the clock.
|
void |
setMinutes(int value)
Sets the minutes to be shown on the clock.
|
void |
setMinutesDotColor(Color c)
Change the Minutes dot color of the clock.
|
void |
setMinutesOffset(int value)
Changes the number of minutes to offset the clock by.
|
void |
setRefreshInterval(int interval)
Change the refresh interval.
|
void |
setSecondHandColor(Color c)
Change the second hand color of the clock.
|
void |
setSeconds(int value)
Sets the seconds to be shown on the clock.
|
void |
setSecondsOffset(int value)
Changes the number of Seconds to offset the clock by.
|
void |
setTime(Date InTime)
Set the display time for the clock when it's not running.
|
void |
start()
Creates and starts a thread that runs the clock
|
void |
stop()
Kills the thread that runs the clock
|
void |
update(Graphics g)
Draws the clock onto the double buffer, and displays it.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public JAnalogClock()
public JAnalogClock(Date InDate)
InDate
- the date class representing the time to set the clock to.public JAnalogClock(int hour, int minute, int second)
hour
- the hour to set the clock tominute
- the minute to set the clock tosecond
- the second to set the clock topublic void setRefreshInterval(int interval)
interval
- the new refresh intervalpublic int getRefreshInterval()
public void setAutoUpdateToolTipText(boolean autoUpdateToolTipText)
value
- true = update the tooltip to match the current clock time.public boolean isAutoUpdateToolTipText()
public void setBackgroundColor(Color c)
c
- the new background colorpublic Color getBackgroundColor()
public void setHourHandColor(Color c)
c
- the new hour hand colorpublic Color getHourHandColor()
public void setMinuteHandColor(Color c)
c
- the new minute hand colorpublic Color getMinuteHandColor()
public void setSecondHandColor(Color c)
c
- the new second hand colorpublic Color getSecondHandColor()
public void setHoursDotColor(Color c)
c
- the new hours dot colorpublic Color getHoursDotColor()
public void setMinutesDotColor(Color c)
c
- the new Minutes dot colorpublic Color getMinutesDotColor()
public void setHourOffset(int value)
value
- the number of hours to offset the clock by. Valid values are +24 to -24.public int getHourOffset()
public void setMinutesOffset(int value)
value
- the number of minutes to offset the clock by. Valid values are +60 to -60.public int getMinutesOffset()
public void setSecondsOffset(int value)
value
- the number of Seconds to offset the clock by. Valid values are +60 to -60.public int getSecondsOffset()
public void setHour(int value)
start()
it will display the actual time from the computer +/- the offsets, not
the values the clock was set to in the constructor or the setHour, setMinutes,
or setSeconds functions. When stop()
is called, the clock will display whatever
the time was when it was stopped. Default is from constructor.value
- the number to set the display hour to. Valid values are 0 to 23.public int getHour()
public void setMinutes(int value)
start()
it will display the actual time from the computer +/- the offsets, not
the values the clock was set to in the constructor or the setHour, setMinutes,
or setSeconds functions. When stop()
is called, the clock will display whatever
the time was when it was stopped. Default is from constructor.value
- the number to set the display minutes to. Valid values are 0 to 59.public int getMinutes()
public void setSeconds(int value)
start()
it will display the actual time from the computer +/- the offsets, not
the values the clock was set to in the constructor or the setHour, setMinutes,
or setSeconds functions. When stop()
is called, the clock will display whatever
the time was when it was stopped. Default is from constructor.value
- the number to set the display seconds to. Valid values are 0 to 59.public int getSeconds()
public boolean isFocusTraversable()
isFocusTraversable
in class Component
public void setTime(Date InTime)
InTime
- A date object representing the current time to display.public Date getTime()
public void start()
public void stop()
public void run()
start
to create the thread.
Do Not call this method directly.public boolean isRunning()
public void update(Graphics g)
update
in class JComponent
g
- The graphics device to draw onpublic void paint(Graphics g)
paint
in class JComponent
g
- The graphics device to draw onCopyright © 2003, 2023, Oracle and/or its affiliates.