Package org.jjazz.uiutilities.api
Class WheelSpinner
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSpinner
org.jjazz.uiutilities.api.WheelSpinner
- All Implemented Interfaces:
MouseWheelListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
A JSpinner with mousewheel support, and some convenience methods.
Supports only SpinnerListModel and SpinnerNumberModel. Mouse-wheel support is enabled according to GeneralUISettings. If model is a SpinnerNumberModel prevent insertion of anything except digit.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JSpinner
JSpinner.DateEditor, JSpinner.DefaultEditor, JSpinner.ListEditor, JSpinner.NumberEditor
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Overridden only to manage changeFromManualEdit.int
int
Wheel step used when ctrl is pressed.int
boolean
boolean
Check if the last ChangeEvent resulted from a manual edit (user typed value), or an increment/decrement action (e.g. using the up/down buttons).boolean
Indicate if spinner loops to min value when max value is reached using the wheel.void
void
setBlockKeyEventForwarding
(boolean b) Block/unblock key event forwarding for printable keys.void
setColumns
(int n) Set the width of the editor so it can display n chars.void
setCtrlWheelStep
(int ctrlWheelStep) Wheel step used when ctrl is pressed.void
setLoopValues
(boolean loopValues) Set whether to loop to min value when max value is reached using the wheel.void
setModel
(SpinnerModel model) void
Same as setValue(Object) but with possibility of NOT notifying change listeners.void
setWheelStep
(int wheelStep) Methods inherited from class javax.swing.JSpinner
addChangeListener, getAccessibleContext, getChangeListeners, getEditor, getModel, getNextValue, getPreviousValue, getUI, getUIClassID, getValue, removeChangeListener, setEditor, setUI, setValue, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
WheelSpinner
public WheelSpinner()
-
-
Method Details
-
setBlockKeyEventForwarding
public void setBlockKeyEventForwarding(boolean b) Block/unblock key event forwarding for printable keys.Key presses are not consumed by JSpinner , they are also processed by the keybinding framework. The Only way is to capture all the keys... /* see https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html
- Parameters:
b
-
-
isBlockKeyEventForwarding
public boolean isBlockKeyEventForwarding()- Returns:
- False by default.
-
setModel
-
getDefaultEditor
-
setValue
Same as setValue(Object) but with possibility of NOT notifying change listeners.- Parameters:
value
-silent
- If true don't notify registered ChangeListeners
-
isLoopValues
public boolean isLoopValues()Indicate if spinner loops to min value when max value is reached using the wheel.- Returns:
- the loopValues
-
setLoopValues
public void setLoopValues(boolean loopValues) Set whether to loop to min value when max value is reached using the wheel.- Parameters:
loopValues
- the loopValues to set
-
setColumns
public void setColumns(int n) Set the width of the editor so it can display n chars.- Parameters:
n
- int
-
getColumns
public int getColumns() -
getWheelStep
public int getWheelStep()- Returns:
- the wheelStep
-
setWheelStep
public void setWheelStep(int wheelStep) - Parameters:
wheelStep
- the wheelStep to set
-
getCtrlWheelStep
public int getCtrlWheelStep()Wheel step used when ctrl is pressed.- Returns:
- the ctrlWheelStep
-
setCtrlWheelStep
public void setCtrlWheelStep(int ctrlWheelStep) Wheel step used when ctrl is pressed.- Parameters:
ctrlWheelStep
- the ctrlWheelStep to set
-
isChangeFromManualEdit
public boolean isChangeFromManualEdit()Check if the last ChangeEvent resulted from a manual edit (user typed value), or an increment/decrement action (e.g. using the up/down buttons).Note: this may not work on all L&F, works at least on Netbeans flatlaf dark.
- Returns:
-
commitEdit
Overridden only to manage changeFromManualEdit.- Overrides:
commitEdit
in classJSpinner
- Throws:
ParseException
-
mouseWheelMoved
- Specified by:
mouseWheelMoved
in interfaceMouseWheelListener
-