|
|||||||||
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 javax.swing.JComponent com.lavantech.gui.comp.ClockPanel
This Component displays a Analog Clock for a given GregorianCalendar. The ClockPanel can be used to display a live Clock. Here is an example.
import com.lavantech.gui.comp.*; import java.util.*; import java.awt.*; import javax.swing.*; class LiveClock extends JPanel implements Runnable { Thread updateThread = null; public boolean liveMode = true; ClockPanel clockPanel = null; public LiveClock() { super(new BorderLayout()); clockPanel = new ClockPanel(new GregorianCalendar()); add(clockPanel, BorderLayout.CENTER); updateThread = new Thread(this); updateThread.start(); } public void run() { while(liveMode) { try { Thread.sleep(1000); } catch(Exception exp) { } clockPanel.setCalendar(new GregorianCalendar()); SwingUtilities.invokeLater(clockPanel); } } public static void main(String args[]) { JFrame frame = new JFrame(); frame.getContentPane().add(new LiveClock()); frame.pack(); frame.show(); } }
Nested Class Summary |
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 | |
ClockPanel(java.util.GregorianCalendar cal)
Constructs a TimePanel with the given GregorianCalendar |
|
ClockPanel(java.util.GregorianCalendar cal,
boolean editable)
Constructs a TimePanel with the given GregorianCalendar |
Method Summary | |
void |
addActionListener(java.awt.event.ActionListener ls)
Add an action listener that will be notified when the time is changed. |
java.util.GregorianCalendar |
getCalendar()
Returns the selected time. |
java.awt.Color |
getFaceColor()
Returns the clock's face color in the default face graphics. |
java.awt.Image |
getFaceImage()
Gets the image used for the clock face. |
int |
getHourFormat()
Gets the hour format for the clock. |
java.awt.Color |
getHourNeedleColor()
Returns the clock's hour needle's color. |
double |
getHourNeedleHeightRatio()
Returns the hour needle height to the clock face radius ratio. |
java.awt.Shape |
getHourNeedleShape()
Returns the shape of the hour needle. |
double |
getHourNeedleWidthRatio()
Returns the hour needle width to the clock face radius ratio. |
java.util.GregorianCalendar |
getMaxSelectableTime()
Returns the maximum time that can be selected. |
java.awt.Color |
getMinNeedleColor()
Gets the clock's minute needle's color |
double |
getMinNeedleHeightRatio()
Returns the minute needle height to the clock face radius ratio. |
java.awt.Shape |
getMinNeedleShape()
Returns the shape of the minute needle. |
double |
getMinNeedleWidthRatio()
Returns the minute needle width to the clock face radius ratio. |
java.util.GregorianCalendar |
getMinSelectableTime()
Returns the minimum time that can be selected. |
java.awt.Color |
getSecNeedleColor()
Gets the clock's second needle's color |
double |
getSecNeedleHeightRatio()
Returns the second needle height to the clock face radius ratio. |
java.awt.Shape |
getSecNeedleShape()
Returns the shape of the seconds needle. |
double |
getSecNeedleWidthRatio()
Returns the second needle width to the clock face radius ratio. |
boolean |
isEditable()
Returns if this ClockPanel is editable |
boolean |
isMinDisplayed()
Returns whether the minute needle is displayed or not. |
boolean |
isSecDisplayed()
Returns whether the second needle is displayed or not. |
void |
mouseClicked(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mouseDragged(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mouseEntered(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mouseExited(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mouseMoved(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mousePressed(java.awt.event.MouseEvent evt)
Implementation side effect. |
void |
mouseReleased(java.awt.event.MouseEvent evt)
Implementation side effect. |
protected void |
paintComponent(java.awt.Graphics g)
|
void |
removeActionListener(java.awt.event.ActionListener ls)
Remove an action listener. |
void |
run()
The run method updates the ClockPanel just like updateTime(). |
void |
setCalendar(java.util.GregorianCalendar cal)
Sets the selected time. |
void |
setEditable(boolean editable)
Sets if the clock is changable |
void |
setEnabled(boolean enable)
Sets whether the ClockPanel is enabled or not. |
void |
setFaceColor(java.awt.Color color)
Sets the clock's face color in the default face graphics. |
void |
setFaceImage(java.awt.Image face)
Sets the image to use for the clock face. |
void |
setHourFormat(int format)
Sets the hour format for the clock. |
void |
setHourNeedleColor(java.awt.Color color)
Sets the clock's hour needle's color. |
void |
setHourNeedleHeightRatio(double ratio)
Sets the relative height of hour needle to the clock face radius. |
void |
setHourNeedleShape(java.awt.Shape newShape)
Sets the hour needle shape. |
void |
setHourNeedleWidthRatio(double ratio)
Sets the relative width of hour needle to the clock face radius. |
void |
setMaxSelectableTime(java.util.GregorianCalendar maxTime)
Set the maximum time that can be selected. |
void |
setMinDisplayed(boolean val)
Sets whether the minute needle is displayed or not. |
void |
setMinNeedleColor(java.awt.Color color)
Sets the clock's minute needle's color. |
void |
setMinNeedleHeightRatio(double ratio)
Sets the relative height of minute needle to the clock face radius. |
void |
setMinNeedleShape(java.awt.Shape newShape)
Sets the minute needle shape. |
void |
setMinNeedleWidthRatio(double ratio)
Sets the relative width of minute needle to the clock face radius. |
void |
setMinSelectableTime(java.util.GregorianCalendar minTime)
Set the minimum time that can be selected. |
void |
setSecDisplayed(boolean val)
Sets whether the second needle is displayed or not. |
void |
setSecNeedleColor(java.awt.Color color)
Sets the clock's second needle's color. |
void |
setSecNeedleHeightRatio(double ratio)
Sets the relative height of second needle to the clock face radius. |
void |
setSecNeedleShape(java.awt.Shape newShape)
Sets the second needle shape. |
void |
setSecNeedleWidthRatio(double ratio)
Sets the relative width of second needle to the clock face radius. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
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, isEnabled, 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 |
public ClockPanel(java.util.GregorianCalendar cal)
cal
- The calendar time to which the clock will be initially set to.public ClockPanel(java.util.GregorianCalendar cal, boolean editable)
cal
- The calendar time to which the clock will be initially set to.editable
- If true, User can change the clock by dragging the needles.Method Detail |
public java.util.GregorianCalendar getMinSelectableTime()
public void setMinSelectableTime(java.util.GregorianCalendar minTime)
minTime
- Minimum time that can be selected in DateTimePicker. null
can be passed to remove minimum limit.
java.lang.IllegalArgumentException
- If minTime is greater than maxSelectableTimepublic java.util.GregorianCalendar getMaxSelectableTime()
public void setMaxSelectableTime(java.util.GregorianCalendar maxTime)
maxTime
- Maximum time that can be selected in DateTimePicker. null
can be passed to remove maximum limit.
java.lang.IllegalArgumentException
- If maxTime is less than minSelectableTimepublic void setEnabled(boolean enable)
public void setEditable(boolean editable)
editable
- If true, User can change the clock by dragging the needles.public boolean isEditable()
protected void paintComponent(java.awt.Graphics g)
public java.util.GregorianCalendar getCalendar()
public void setCalendar(java.util.GregorianCalendar cal)
public void run()
run
in interface java.lang.Runnable
public void setHourFormat(int format)
public int getHourFormat()
public java.awt.Color getFaceColor()
public void setFaceColor(java.awt.Color color)
public java.awt.Color getHourNeedleColor()
public void setHourNeedleColor(java.awt.Color color)
public java.awt.Color getMinNeedleColor()
public void setMinNeedleColor(java.awt.Color color)
public java.awt.Color getSecNeedleColor()
public void setSecNeedleColor(java.awt.Color color)
public java.awt.Image getFaceImage()
public void setFaceImage(java.awt.Image face)
public java.awt.Shape getHourNeedleShape()
public void setHourNeedleShape(java.awt.Shape newShape)
setHourNeedleHeightRatio(double)
,
setHourNeedleWidthRatio(double)
public java.awt.Shape getMinNeedleShape()
public void setMinNeedleShape(java.awt.Shape newShape)
setMinNeedleHeightRatio(double)
,
setMinNeedleWidthRatio(double)
public java.awt.Shape getSecNeedleShape()
public void setSecNeedleShape(java.awt.Shape newShape)
setSecNeedleHeightRatio(double)
,
setSecNeedleWidthRatio(double)
public double getHourNeedleHeightRatio()
public void setHourNeedleHeightRatio(double ratio)
public double getHourNeedleWidthRatio()
public void setHourNeedleWidthRatio(double ratio)
public double getMinNeedleHeightRatio()
public void setMinNeedleHeightRatio(double ratio)
public double getMinNeedleWidthRatio()
public void setMinNeedleWidthRatio(double ratio)
public double getSecNeedleHeightRatio()
public void setSecNeedleHeightRatio(double ratio)
public double getSecNeedleWidthRatio()
public void setSecNeedleWidthRatio(double ratio)
public boolean isMinDisplayed()
public void setMinDisplayed(boolean val)
public boolean isSecDisplayed()
public void setSecDisplayed(boolean val)
public void mouseClicked(java.awt.event.MouseEvent evt)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent evt)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent evt)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent evt)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent evt)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent evt)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void addActionListener(java.awt.event.ActionListener ls)
public void removeActionListener(java.awt.event.ActionListener ls)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |