com.isti.util.gui
Class IstiClockPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.isti.util.gui.IstiClockPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class IstiClockPanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener

Class IstiClockPanel implements a clock panel that displays the current time.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.util.TimeZone DEFAULT_TIME_ZONE
          Value to use when the default time zone is desired.
static int DISPMODE_ALWAYS_SHOW_DEFAULT_TIME_ZONE
          Display mode value (displayMode): Always show the default time zone
static int DISPMODE_DEFAULT
          Display mode value (displayMode): Default mode - only show the selected time zone
static int DISPMODE_SHOW_LOCAL_WHEN_DEFAULT
          Display mode value (displayMode): Show local time zone when the default time zone is selected.
static int SHOW_24_HOUR_COMMAND
          Command to show the time in 24 hour mode on the display.
static int SHOW_ALL_TIME_ZONES_COMMAND
          Command to show the all time zones on the display.
static int SHOW_SECOND_TIME_ZONE_COMMAND
          Command to show the second time zone on the display if more than one time zone is displayed.
static int SHOW_SECONDS_COMMAND
          Command to show seconds on the display.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
IstiClockPanel()
          Creates a clock panel with the default time zone.
IstiClockPanel(java.util.TimeZone zone)
          Creates a clock panel with the specified time zone.
IstiClockPanel(java.util.TimeZone zone, int displayMode)
          Creates a clock panel with the specified time zone.
IstiClockPanel(java.util.TimeZone zone, int displayMode, java.util.TimeZone defaultZone)
          Creates a clock panel with the specified time zone.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Implements the ActionListener interface.
protected  void addMenuItem(int command)
          Adds a menu item to the popup menu.
 boolean disableCommand(int command)
          Disables the specified command.
 boolean getCommandState(int command)
          Gets the state for the specified command.
protected  javax.swing.JCheckBoxMenuItem getMenuItem(int command)
          Gets the menu item for the specified command.
 void init(java.util.TimeZone zone, int displayMode)
          Initializes the time zone values.
 boolean isCommandEnabled(int command)
          Determines if the specified command is enabled.
 boolean isFloatable()
          Returns the "floatable" property for the panel.
 boolean isRunning()
          Returns true if the clock is running.
 void restart()
          Restart the clock.
 boolean setCommandEnable(int command, boolean b)
          Enables/disables the specified command.
 boolean setCommandState(int command, boolean b)
          Sets the state for the specified command.
 void setFloatable(boolean flgVal)
          Sets the "floatable" property for the panel.
protected  void setMenuItemEnable(javax.swing.JCheckBoxMenuItem mi, boolean b)
          Enables/disables the specified menu item.
 void setPopupEnabled(boolean b)
          Enable/disables popup menu.
 void setTimeZone(java.util.TimeZone zone)
          Sets the time zone.
 void start()
          Starts the clock.
 void stop()
          Stops the clock.
protected  boolean updateCommandState(int command)
          Updates the state for the specified command.
protected  boolean updateCommandState(int command, boolean b)
          Updates the state for the specified command.
protected  boolean updateCommandState(java.lang.String actionCommand)
          Updates the state for the specified command.
protected  void updateDateFormatString(boolean firstTimeZone)
          Updates the date format string.
protected  java.util.Calendar updateTime()
          Updates the time on the display.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, update
 
Methods inherited from class java.awt.Container
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, 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, 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, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHOW_ALL_TIME_ZONES_COMMAND

public static final int SHOW_ALL_TIME_ZONES_COMMAND
Command to show the all time zones on the display.

See Also:
Constant Field Values

SHOW_SECONDS_COMMAND

public static final int SHOW_SECONDS_COMMAND
Command to show seconds on the display.

See Also:
Constant Field Values

SHOW_24_HOUR_COMMAND

public static final int SHOW_24_HOUR_COMMAND
Command to show the time in 24 hour mode on the display.

See Also:
Constant Field Values

SHOW_SECOND_TIME_ZONE_COMMAND

public static final int SHOW_SECOND_TIME_ZONE_COMMAND
Command to show the second time zone on the display if more than one time zone is displayed.

See Also:
Constant Field Values

DEFAULT_TIME_ZONE

public static final java.util.TimeZone DEFAULT_TIME_ZONE
Value to use when the default time zone is desired.


DISPMODE_DEFAULT

public static final int DISPMODE_DEFAULT
Display mode value (displayMode): Default mode - only show the selected time zone

See Also:
Constant Field Values

DISPMODE_ALWAYS_SHOW_DEFAULT_TIME_ZONE

public static final int DISPMODE_ALWAYS_SHOW_DEFAULT_TIME_ZONE
Display mode value (displayMode): Always show the default time zone

See Also:
Constant Field Values

DISPMODE_SHOW_LOCAL_WHEN_DEFAULT

public static final int DISPMODE_SHOW_LOCAL_WHEN_DEFAULT
Display mode value (displayMode): Show local time zone when the default time zone is selected. NOTE: Normally used with DISPMODE_ALWAYS_SHOW_DEFAULT_TIME_ZONE.

See Also:
Constant Field Values
Constructor Detail

IstiClockPanel

public IstiClockPanel()
Creates a clock panel with the default time zone. The 'start' method needs to be called to start the clock after the clock panel is setup.

See Also:
start

IstiClockPanel

public IstiClockPanel(java.util.TimeZone zone)
Creates a clock panel with the specified time zone.

Parameters:
zone - time zone for the clock or DEFAULT_TIME_ZONE for default. The 'start' method needs to be called to start the clock after the clock panel is setup.
See Also:
start

IstiClockPanel

public IstiClockPanel(java.util.TimeZone zone,
                      int displayMode)
Creates a clock panel with the specified time zone.

Parameters:
zone - time zone for the clock or DEFAULT_TIME_ZONE for default.
displayMode - display mode. The 'start' method needs to be called to start the clock after the clock panel is setup.
See Also:
start, DISPMODE_*

IstiClockPanel

public IstiClockPanel(java.util.TimeZone zone,
                      int displayMode,
                      java.util.TimeZone defaultZone)
Creates a clock panel with the specified time zone.

Parameters:
zone - time zone for the clock or DEFAULT_TIME_ZONE for default.
displayMode - display mode.
defaultZone - default time zone for the clock or DEFAULT_TIME_ZONE for system default. The 'start' method needs to be called to start the clock after the clock panel is setup.
See Also:
start, DISPMODE_*
Method Detail

init

public void init(java.util.TimeZone zone,
                 int displayMode)
Initializes the time zone values.

Parameters:
zone - time zone.
displayMode - display mode.
See Also:
DISPMODE_*

setTimeZone

public void setTimeZone(java.util.TimeZone zone)
Sets the time zone.

Parameters:
zone - time zone.

getCommandState

public boolean getCommandState(int command)
Gets the state for the specified command.

Parameters:
command - the command.
Returns:
true if command is enabled.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

disableCommand

public boolean disableCommand(int command)
Disables the specified command.

Parameters:
command - the command.
Returns:
true if valid command.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

setCommandEnable

public boolean setCommandEnable(int command,
                                boolean b)
Enables/disables the specified command.

Parameters:
command - the command.
b - true if the command should be enabled.
Returns:
true if valid command.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

getMenuItem

protected javax.swing.JCheckBoxMenuItem getMenuItem(int command)
Gets the menu item for the specified command.

Parameters:
command - the command.
Returns:
the menu item or null if none.

setMenuItemEnable

protected void setMenuItemEnable(javax.swing.JCheckBoxMenuItem mi,
                                 boolean b)
Enables/disables the specified menu item.

Parameters:
mi - the menu item.
b - true if the command should be enabled.

isCommandEnabled

public boolean isCommandEnabled(int command)
Determines if the specified command is enabled.

Parameters:
command - the command.
Returns:
true if the command is enabled.

setCommandState

public boolean setCommandState(int command,
                               boolean b)
Sets the state for the specified command.

Parameters:
command - the command.
b - command state.
Returns:
true if valid command.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

setPopupEnabled

public void setPopupEnabled(boolean b)
Enable/disables popup menu.

Parameters:
b - true if popups should be enabled.

updateCommandState

protected boolean updateCommandState(int command,
                                     boolean b)
Updates the state for the specified command.

Parameters:
command - the command.
b - command state.
Returns:
true if valid command.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

updateCommandState

protected boolean updateCommandState(int command)
Updates the state for the specified command.

Parameters:
command - the command.
Returns:
true if valid command.
See Also:
SHOW_ALL_TIME_ZONES_COMMAND, SHOW_SECONDS_COMMAND, ...

updateCommandState

protected boolean updateCommandState(java.lang.String actionCommand)
Updates the state for the specified command.

Parameters:
actionCommand - the action command string.
Returns:
true if valid command.
See Also:
popupCommands

updateDateFormatString

protected void updateDateFormatString(boolean firstTimeZone)
Updates the date format string.

Parameters:
firstTimeZone - true if first time zone should be updated.

addMenuItem

protected void addMenuItem(int command)
Adds a menu item to the popup menu.

Parameters:
command - command index.

start

public void start()
Starts the clock.


isRunning

public boolean isRunning()
Returns true if the clock is running.

Returns:
true if the clock is running.
See Also:
start()

restart

public void restart()
Restart the clock.


stop

public void stop()
Stops the clock.


updateTime

protected java.util.Calendar updateTime()
Updates the time on the display.

Returns:
current date

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Implements the ActionListener interface. Invoked when an action occurs.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - action event.

setFloatable

public void setFloatable(boolean flgVal)
Sets the "floatable" property for the panel.

Parameters:
flgVal - true to enable; false to disable.

isFloatable

public boolean isFloatable()
Returns the "floatable" property for the panel.

Returns:
true if enabled; false if disabled.