public class TimeSelector extends JComponent implements PropertyChangeListener
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected JAnalogClock |
mAnalogClock |
protected TimeChanger |
mChanger |
protected JPopupMenu |
mTimePopup |
protected JButton |
mTimePopupInvoker |
protected JTextField |
mTimeTF |
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 |
---|
TimeSelector()
Creates a new TimeSelector instance comprised of a JTextField and
an selectable icon to the right of the JTextField.
|
TimeSelector(boolean showTime)
Creates a new TimeSelector instance comprised of a JTextField and
an selectable icon to the right of the JTextField.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Adds a change listener to the textfield
|
Color |
getBackground()
Gets the TextField's background color
|
Color |
getBackgroundColor()
Retrieves the clock background color
|
Color |
getForeground()
Gets the TextField's Foreground color
|
int |
getHour()
Gets the hour displayed by the clock
|
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()
Gets the minutes displayed by the clock
|
Color |
getMinutesDotColor()
Retrieves the Minutes dot color
|
int |
getMinutesOffset()
Retrieves the Minute offset value
|
String |
getPattern()
Retrieves the date pattern used to render the time into the textfield
|
Color |
getSecondHandColor()
Retrieves the second hand color
|
int |
getSeconds()
Gets the seconds displayed by the clock
|
int |
getSecondsOffset()
Retrieves the Seconds offset value
|
boolean |
getShowPatternTip()
Indicates if the tooltip is displayed or not.
|
String |
getText()
Retrieves the contents of the date textfield.
|
Date |
getTime()
Retrieves the current time represented by this component.
|
void |
hidePopup()
Provides a way to force the pop-up to hide
|
boolean |
isEditable()
Returns true if component is editable
|
void |
paintComponent(Graphics g)
Repaints the component
|
void |
propertyChange(PropertyChangeEvent e)
Watch for user selection date changesmTimePopup from the analogClock component
|
void |
removeChangeListener(ChangeListener l)
Removes a change listener from the textbox
|
void |
requestFocus()
Override requestFocus to pass it on to the actual text field
|
void |
setBackground(Color bg)
Sets the TextField's background color
|
void |
setBackgroundColor(Color c)
Change the background color of the clock.
|
void |
setEditable(boolean editable)
Set editability of component
|
void |
setEnabled(boolean b)
Enables/disables the subcomponents that comprise the main component
|
void |
setForeground(Color fc)
Sets the TextField's Foreground color
|
void |
setHour(int value)
Sets the hour to be displayed by 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 displayed by 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 |
setPattern(String p) |
void |
setSecondHandColor(Color c)
Change the second hand color of the clock.
|
void |
setSeconds(int value)
Sets the seconds to be displayed by the clock
|
void |
setSecondsOffset(int value)
Changes the number of Seconds to offset the clock by.
|
void |
setShowPatternTip(boolean b)
Turns on/off the tooltip displaying the current date pattern.
|
void |
setTime(Date d)
Establishes the current time represented by this component
|
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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, getAccessibleContext, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, 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, 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, transferFocusBackward, transferFocusUpCycle
protected JTextField mTimeTF
protected JButton mTimePopupInvoker
protected JPopupMenu mTimePopup
protected JAnalogClock mAnalogClock
protected TimeChanger mChanger
public TimeSelector()
public TimeSelector(boolean showTime)
showTime
- determines if today's time is displayed in the
textfield initially. If showTime is false, the textfield is initially
blank and the tooltip (containing the time pattern) is turned on.public void hidePopup()
public void requestFocus()
requestFocus
in class JComponent
public Color getBackground()
getBackground
in class Component
public void setBackground(Color bg)
setBackground
in class JComponent
bg
- Color to set background topublic Color getForeground()
getForeground
in class Component
public void setForeground(Color fc)
setForeground
in class JComponent
fc
- color to set the foreground topublic void addChangeListener(ChangeListener l)
l
- changeListener to addpublic void removeChangeListener(ChangeListener l)
l
- changeListener to removepublic void paintComponent(Graphics g)
paintComponent
in class JComponent
g
- - graphics to paint onpublic void setShowPatternTip(boolean b)
b
- the flag dictating if the tooltip should be on or offpublic void setEditable(boolean editable)
editable
- New editable flagpublic boolean isEditable()
public boolean getShowPatternTip()
public String getPattern()
public void setPattern(String p)
public String getText()
public Date getTime() throws IllegalArgumentException
IllegalArgumentException
public void setTime(Date d)
d
- the new datepublic void setHour(int value)
value
- the number representing the current hourpublic int getHour()
public void setMinutes(int value)
value
- the number representing the current minutespublic int getMinutes()
public void setSeconds(int value)
value
- the number representing the current secondspublic int getSeconds()
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 setEnabled(boolean b)
setEnabled
in class JComponent
b
- If true, the component is enabled; otherwise it is disabled.public void propertyChange(PropertyChangeEvent e)
propertyChange
in interface PropertyChangeListener
e
- property change eventCopyright © 2003, 2023, Oracle and/or its affiliates.