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.NumberEditorNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested 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_WINDOWFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidOverridden only to manage changeFromManualEdit.intintWheel step used when ctrl is pressed.intbooleanbooleanCheck if the last ChangeEvent resulted from a manual edit (user typed value), or an increment/decrement action (e.g. using the up/down buttons).booleanIndicate if spinner loops to min value when max value is reached using the wheel.voidvoidsetBlockKeyEventForwarding(boolean b) Block/unblock key event forwarding for printable keys.voidsetColumns(int n) Set the width of the editor so it can display n chars.voidsetCtrlWheelStep(int ctrlWheelStep) Wheel step used when ctrl is pressed.voidsetLoopValues(boolean loopValues) Set whether to loop to min value when max value is reached using the wheel.voidsetModel(SpinnerModel model) voidSame as setValue(Object) but with possibility of NOT notifying change listeners.voidsetWheelStep(int wheelStep) Methods inherited from class javax.swing.JSpinner
addChangeListener, getAccessibleContext, getChangeListeners, getEditor, getModel, getNextValue, getPreviousValue, getUI, getUIClassID, getValue, removeChangeListener, setEditor, setUI, setValue, updateUIMethods 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, updateMethods 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, validateMethods 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:
commitEditin classJSpinner- Throws:
ParseException
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-