|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractAction javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler
A handler for spinner arrow button mouse and action events. When a left mouse pressed event occurs we look up the (enabled) spinner that's the source of the event and start the autorepeat timer. The timer fires action events until any button is released at which point the timer is stopped and the reference to the spinner cleared. The timer doesn't start until after a 300ms delay, so often the source of the initial (and final) action event is just the button logic for mouse released - which means that we're relying on the fact that our mouse listener runs after the buttons mouse listener.
Note that one instance of this handler is shared by all slider previous arrow buttons and likewise for all of the next buttons, so it doesn't have any state that persists beyond the limits of a single button pressed/released gesture.
Nested Class Summary |
Nested classes inherited from class javax.swing.AbstractAction |
|
Field Summary | |
(package private) Timer |
autoRepeatTimer
|
(package private) boolean |
isNext
|
(package private) JSpinner |
spinner
|
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
(package private) |
BasicSpinnerUI.ArrowButtonHandler(String name,
boolean isNext)
|
Method Summary | |
void |
actionPerformed(ActionEvent e)
Invoked when an action occurs. |
private JSpinner |
eventToSpinner(AWTEvent e)
|
private void |
focusSpinnerIfNecessary()
Requests focus on a child of the spinner if the spinner doesn't have focus. |
private int |
getCalendarField(JSpinner spinner)
Returns the calendarField under the start of the selection, or -1 if there is no valid calendar field under the selection (or the spinner isn't editing dates. |
void |
mouseClicked(MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component. |
void |
mouseEntered(MouseEvent e)
Invoked when the mouse enters a component. |
void |
mouseExited(MouseEvent e)
Invoked when the mouse exits a component. |
void |
mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component. |
void |
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component. |
private boolean |
select(JFormattedTextField ftf,
AttributedCharacterIterator iterator,
DateFormat.Field field)
Selects the passed in field, returning true if it is found, false otherwise. |
private void |
select(JSpinner spinner)
If the spinner's editor is a DateEditor, this selects the field associated with the value that is being incremented. |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
final Timer autoRepeatTimer
final boolean isNext
JSpinner spinner
Constructor Detail |
BasicSpinnerUI.ArrowButtonHandler(String name, boolean isNext)
Method Detail |
private JSpinner eventToSpinner(AWTEvent e)
public void actionPerformed(ActionEvent e)
ActionListener
actionPerformed
in interface ActionListener
private void select(JSpinner spinner)
private boolean select(JFormattedTextField ftf, AttributedCharacterIterator iterator, DateFormat.Field field)
private int getCalendarField(JSpinner spinner)
public void mousePressed(MouseEvent e)
MouseListener
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
MouseListener
mouseReleased
in interface MouseListener
public void mouseClicked(MouseEvent e)
MouseListener
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent e)
MouseListener
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
MouseListener
mouseExited
in interface MouseListener
private void focusSpinnerIfNecessary()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |