com.lavantech.gui.comp
Class TimePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.lavantech.gui.comp.TimePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, javax.swing.event.ChangeListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TimePanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener, javax.swing.event.ChangeListener

TimePanel displays the given time in a digital and analog format for a user to change the given time. The time that needs to be displayed/edited is passed as a GregorianCalendar object to the constructor. The edited time is returned by getCalendar() method.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
 
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
TimePanel()
          Constructs a TimePanel with the current Date Time.
TimePanel(java.util.GregorianCalendar cal)
          Constructs a TimePanel with the given GregorianCalendar.
TimePanel(java.util.GregorianCalendar cal, java.util.Locale locale)
          Constructs a TimePanel with the given GregorianCalendar.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Implementation side effect
 void addActionListener(java.awt.event.ActionListener ls)
          Adds an ActionListener.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a propertyChangeListener.
 java.util.GregorianCalendar getCalendar()
          Returns the selected Time.
 ClockPanel getClockPanel()
          Returns the clockPanel inside the Time panel
 boolean getDisplayAnalog()
          Returns whether the time in analog clock will be displayed.
 boolean getDisplayDigital()
          Returns whether the time in digital form will be displayed.
 java.awt.Color getFaceColor()
          Returns the clock's face color.
 java.awt.Color getHourNeedleColor()
          Returns the clock hour needle color
 java.util.GregorianCalendar getMaxSelectableTime()
          Returns the maximum time that can be selected.
 java.awt.Color getMinNeedleColor()
          Gets the clock minute needle color
 java.util.GregorianCalendar getMinSelectableTime()
          Returns the minimum time that can be selected.
 java.awt.Color getSecNeedleColor()
          Gets the clock second needle color
 boolean isEditable()
          Returns whether the time in the TimePanel can be changed by the user.
 boolean isEnabled()
          Returns whether the TimePanel is enabled or not.
 boolean isHourMinSecLabelDisplayed()
          Returns whether the hour, min and sec label above the digital time is displayed or not.
 boolean isMinDisplayed()
          Returns whether minute is displayed or not.
 boolean isSecDisplayed()
          Returns whether second is displayed or not.
 void removeActionListener(java.awt.event.ActionListener ls)
          Removes an ActionListener
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a propertyChangeListner.
 void setBackground(java.awt.Color bg)
          Set the background color of this component.
 void setCalendar(java.util.GregorianCalendar cal)
          Sets the selected time.
 void setDisplayAnalog(boolean disp)
          Sets whether Analog Clock will be displayed in the Time Panel.
 void setDisplayDigital(boolean disp)
          Sets whether Digital time will be displayed in the Time Panel.
 void setEditable(boolean edit)
          Sets whether the time in the TimePanel can be changed by the user.
 void setEnabled(boolean enable)
          Sets whether the TimePanel is enabled or not.
 void setFaceColor(java.awt.Color color)
          Sets the clock's face color.
 void setFont(java.awt.Font font)
          Set the font for this component.
 void setForeground(java.awt.Color fg)
          Set the foreground color of this component.
 void setHourMinSecLabelDisplayed(boolean disp)
          Sets whether the hour, min and sec label above the digital time is displayed or not.
 void setHourNeedleColor(java.awt.Color color)
          Sets the clock hour needle color
 void setMaxSelectableTime(java.util.GregorianCalendar maxTime)
          Set the maximum time that can be selected.
 void setMinDisplayed(boolean val)
          Sets whether the minute is displayed or not.
 void setMinNeedleColor(java.awt.Color color)
          Sets the clock minute needle color
 void setMinSelectableTime(java.util.GregorianCalendar minTime)
          Set the minimum time that can be selected.
 void setSecDisplayed(boolean val)
          Sets whether the second is displayed or not.
 void setSecNeedleColor(java.awt.Color color)
          Sets the clock second needle color
 void setToolTipText(java.lang.String text)
          Set the ToolTip Text for this component.
 void stateChanged(javax.swing.event.ChangeEvent evt)
          Implementation side effect
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Constructor Detail

TimePanel

public TimePanel()
Constructs a TimePanel with the current Date Time.


TimePanel

public TimePanel(java.util.GregorianCalendar cal)
Constructs a TimePanel with the given GregorianCalendar.

Parameters:
cal - The GregorianCalendar that needs to be displayed/edited

TimePanel

public TimePanel(java.util.GregorianCalendar cal,
                 java.util.Locale locale)
Constructs a TimePanel with the given GregorianCalendar.

Parameters:
cal - The GregorianCalendar that needs to be displayed/edited
locale - The locale that will be used to display "AM/PM" string.
Method Detail

isMinDisplayed

public boolean isMinDisplayed()
Returns whether minute is displayed or not.


setMinDisplayed

public void setMinDisplayed(boolean val)
Sets whether the minute is displayed or not.


isSecDisplayed

public boolean isSecDisplayed()
Returns whether second is displayed or not.


setSecDisplayed

public void setSecDisplayed(boolean val)
Sets whether the second is displayed or not.


setHourMinSecLabelDisplayed

public void setHourMinSecLabelDisplayed(boolean disp)
Sets whether the hour, min and sec label above the digital time is displayed or not.


isHourMinSecLabelDisplayed

public boolean isHourMinSecLabelDisplayed()
Returns whether the hour, min and sec label above the digital time is displayed or not.


getMinSelectableTime

public java.util.GregorianCalendar getMinSelectableTime()
Returns the minimum time that can be selected. If there is no minimum time limit, null is returned.

Returns:
GregorianCalendar Minimum time that can be selected or null if no minimum time limit.

setMinSelectableTime

public void setMinSelectableTime(java.util.GregorianCalendar minTime)
                          throws java.lang.IllegalArgumentException
Set the minimum time that can be selected. If the current selected time is less than the minimum time, the current selected time is set to the minimum time.

Parameters:
minTime - Minimum time that can be selected in DateTimePicker. null can be passed to remove minimum limit.
Throws:
java.lang.IllegalArgumentException - If minTime is greater than maxSelectableTime

getMaxSelectableTime

public java.util.GregorianCalendar getMaxSelectableTime()
Returns the maximum time that can be selected. If there is no maximum time limit, null is returned.

Returns:
GregorianCalendar Maximum time that can be selected or null if no maximum time limit.

setMaxSelectableTime

public void setMaxSelectableTime(java.util.GregorianCalendar maxTime)
                          throws java.lang.IllegalArgumentException
Set the maximum time that can be selected. If the current selected time is greater than the maximum time, the current selected time is set to the maximum time.

Parameters:
maxTime - Maximum time that can be selected in DateTimePicker. null can be passed to remove maximum limit.
Throws:
java.lang.IllegalArgumentException - If maxTime is less than minSelectableTime

isEnabled

public boolean isEnabled()
Returns whether the TimePanel is enabled or not.


setEnabled

public void setEnabled(boolean enable)
Sets whether the TimePanel is enabled or not.


isEditable

public boolean isEditable()
Returns whether the time in the TimePanel can be changed by the user.


setEditable

public void setEditable(boolean edit)
Sets whether the time in the TimePanel can be changed by the user.


getDisplayDigital

public boolean getDisplayDigital()
Returns whether the time in digital form will be displayed.


setDisplayDigital

public void setDisplayDigital(boolean disp)
Sets whether Digital time will be displayed in the Time Panel. Both DisplayDigital and DisplayAnalog cannot be false. If DisplayAnalog is already false and this method is called to set DisplayDigital to false, then DisplayAnalog will be set to true.


getDisplayAnalog

public boolean getDisplayAnalog()
Returns whether the time in analog clock will be displayed.


setDisplayAnalog

public void setDisplayAnalog(boolean disp)
Sets whether Analog Clock will be displayed in the Time Panel. Both DisplayDigital and DisplayAnalog cannot be false. If DisplayDigital is already false and this method is called to set DisplayAnalog to false, then DisplayDigital will be set to true.


getCalendar

public java.util.GregorianCalendar getCalendar()
Returns the selected Time.


setCalendar

public void setCalendar(java.util.GregorianCalendar cal)
Sets the selected time. If a minSelectableTime was set and the given time is less than the minSelectableTime, the time is set to the minSelectableTime. Similar check is done for maxSelectableTime also.


setFont

public void setFont(java.awt.Font font)
Set the font for this component.

Parameters:
font - the desired Font for this component

setForeground

public void setForeground(java.awt.Color fg)
Set the foreground color of this component.

Parameters:
fg - the desired foreground Color.

setBackground

public void setBackground(java.awt.Color bg)
Set the background color of this component.

Parameters:
bg - the desired background Color.

setToolTipText

public void setToolTipText(java.lang.String text)
Set the ToolTip Text for this component.

Parameters:
text - the desired tooltip text. If text is null, tooltip is turned off.

getClockPanel

public ClockPanel getClockPanel()
Returns the clockPanel inside the Time panel


addActionListener

public void addActionListener(java.awt.event.ActionListener ls)
Adds an ActionListener. The listeners are notified when the time is changed in this panel.


removeActionListener

public void removeActionListener(java.awt.event.ActionListener ls)
Removes an ActionListener


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a propertyChangeListener.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a propertyChangeListner.


getFaceColor

public java.awt.Color getFaceColor()
Returns the clock's face color.


setFaceColor

public void setFaceColor(java.awt.Color color)
Sets the clock's face color.


getHourNeedleColor

public java.awt.Color getHourNeedleColor()
Returns the clock hour needle color


setHourNeedleColor

public void setHourNeedleColor(java.awt.Color color)
Sets the clock hour needle color


getMinNeedleColor

public java.awt.Color getMinNeedleColor()
Gets the clock minute needle color


setMinNeedleColor

public void setMinNeedleColor(java.awt.Color color)
Sets the clock minute needle color


getSecNeedleColor

public java.awt.Color getSecNeedleColor()
Gets the clock second needle color


setSecNeedleColor

public void setSecNeedleColor(java.awt.Color color)
Sets the clock second needle color


stateChanged

public void stateChanged(javax.swing.event.ChangeEvent evt)
Implementation side effect

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Implementation side effect

Specified by:
actionPerformed in interface java.awt.event.ActionListener