public class SpinnerTimerControl extends JPanel
JPanel
contains a JSpinner
and a
TimerControlPanel
handling a timer iterating through the SpinnerModel's
sequence.
Clicks on the timer's buttons have the following effects:
action | ![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
left mouse click | runs the timer backward through the spinner's sequence | resets to value 0 if it is in the domain and the SpinnerModel
is a SpinnerNumberModel , otherwise does nothing |
runs the timer forward through the spinner's sequence | stops the timer |
right mouse click | jump to the minimum value of the spinner's sequence (only if the
SpinnerModel is a SpinnerNumberModel and a lower
limit is set, otherwise the timer if running will stop at the current value) |
does nothing | jump to the maximum value of the spinner's sequence (only if the
SpinnerModel is a SpinnerNumberModel and an upper
limit is set, otherwise the timer if running will stop at the current value) |
does nothing |
Note:
is only seen, if the timer is not running
is only seen, if the timer is running
ArrowIcon
,
SquareIcon
,
RectanglesIcon
,
Serialized FormJPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
HORIZONTAL
Final variable to adjust the two UI components
JSpinner and
TimerControlPanel horizontally. |
static int |
VERTICAL
Final variable to adjust the two UI components
JSpinner and
TimerControlPanel vertically. |
static String |
ZERO_STRING |
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 |
---|
SpinnerTimerControl()
|
SpinnerTimerControl(SpinnerModel spinnerModel)
Creates a new
SpinnerTimerControl with the
specified SpinnerModel as the current
SpinnerModel . |
SpinnerTimerControl(SpinnerModel spinnerModel,
int adjustment)
Creates a new
SpinnerTimerControl with the specified
SpinnerModel as the current SpinnerModel . |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Adds a listener to the list that is notified each time a change to the
spinner's model occurs.
|
protected void |
fireStateChanged()
Sends a ChangeEvent, whose source is this SpinnerTimerControl, to each listener
which was added to this SpinnerTimerControl.
|
int |
getLayoutAdjustment()
Returns the current layout adjustment.
|
SpinnerModel |
getSpinnerModel()
Returns the current
SpinnerModel . |
SharableTimer |
getTimer()
Returns the SharableTimer this' TimerControlPanel is
using.
|
int |
getTimerDelay()
Returns the current timer delay in msec.
|
void |
removeChangeListener(ChangeListener l)
Removes a ChangeListener from this SpinnerTimerControl.
|
void |
setLayoutAdjustment(int newAdjustment)
Sets a new layout adjustment and revalidates this
JPanel's component tree. |
void |
setSpinnerModel(SpinnerModel newModel)
Sets this'
SpinnerModel to the specified one. |
void |
setTimer(SharableTimer timer)
Sets a new SharableTimer this' TimerControlPanel
should use.
|
void |
setTimerDelay(int newDelay)
Sets the timer delay (in msec) to
newDelay . |
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, 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
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, 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
public static final int HORIZONTAL
JSpinner
and
TimerControlPanel
horizontally.public static final int VERTICAL
JSpinner
and
TimerControlPanel
vertically.public static final String ZERO_STRING
public SpinnerTimerControl()
SpinnerTimerControl
with a
SpinnerNumberModel
as the current
SpinnerModel
. The adjustment of the JSpinner
and TimerControlPanel
is HORIZONTAL.public SpinnerTimerControl(SpinnerModel spinnerModel)
SpinnerTimerControl
with the
specified SpinnerModel
as the current
SpinnerModel
. The adjustment of the
JSpinner
and TimerControlPanel
is HORIZONTAL.public SpinnerTimerControl(SpinnerModel spinnerModel, int adjustment)
SpinnerTimerControl
with the specified
SpinnerModel
as the current SpinnerModel
.
The int value specifies the adjustment of the UI components
JSpinner
and TimerControlPanel
to each other. Use one of the final fields
HORIZONTAL
and VERTICAL
.adjustment
- HORIZONTAL
or VERTICAL
.public void addChangeListener(ChangeListener l)
l
- the ChangeListener to addprotected void fireStateChanged()
addChangeListener(ChangeListener l)
public int getLayoutAdjustment()
public SpinnerModel getSpinnerModel()
SpinnerModel
.SpinnerModel
.setSpinnerModel(SpinnerModel)
public SharableTimer getTimer()
TimerControlPanel.getTimer()
public int getTimerDelay()
setTimerDelay(int)
,
Timer.getDelay()
public void removeChangeListener(ChangeListener l)
l
- the listener to remove.public void setLayoutAdjustment(int newAdjustment)
JPanel's
component tree.
Possible adjustments are: HORIZONTAL
, VERTICAL
.newAdjustment
- The new layout adjustment.public void setSpinnerModel(SpinnerModel newModel)
SpinnerModel
to the specified one.newModel
- The new SpinnerModel
.getSpinnerModel()
public void setTimer(SharableTimer timer)
timer
- the new Timer.TimerControlPanel.setTimer(SharableTimer)
public void setTimerDelay(int newDelay)
newDelay
.newDelay
- The new timer delay in msec.getTimerDelay()