Package cz.fidentis.analyst.gui.elements
Class SpinSlider
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
cz.fidentis.analyst.gui.elements.SpinSlider
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
SpinSlider implements a combination of horizontal slider and input text field (Spinner).
The slider and the spinner are synchronized automatically.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSliderListener
(ActionListener listener) Be informed when the slider changes.void
addSpinnerListener
(ActionListener listener) Be informed when the spinner's value changes.getValue()
Returns current value reflecting the slider's position.protected final void
void
initDouble
(double value, double min, double max, int fractionDigits) Initializes this spin-slider to doubles.void
initInteger
(int value, int min, int max, int stepSize) Initializes this spin-slider to integers.void
initPercentage
(int value) Initializes this spin-slider to percents.void
initPercentage
(int value, int min, int max) Initializes this spin-slider to percents in given range.boolean
Iftrue
, then the spinner is updated continuously during the slider move.final void
setContinuousSync
(boolean continuousSync) Iftrue
, then the spinner is updated continuously during the slider move.void
setEnabled
(boolean enabled) void
setSliderSize
(int size) Sets the width of slider.void
Sets the value.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
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, paintComponent, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printComponent, printChildren, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
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
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, checkImage, checkImage, 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, requestFocus, 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
-
SpinSlider
public SpinSlider()Constructor that creates percentage spin-slider. CallinitDouble(double, double, double, int)
orinitInteger(int, int, int, int)
to change it.
-
-
Method Details
-
getValue
Returns current value reflecting the slider's position. Even if the postponed synchronization is turned on (seesetContinuousSync(boolean)
), the correct value is computed and returned anyway.Based on the type, the return value is
INTEGER
: AnInteger
from set range.DOUBLE
: AnDouble
from set range.PERCENTAGE
: AnInteger
between 0 and 100.
Usage:
- After
initDouble()
:double var = (Double) spinSlider.getValue()
. - After
initInteger()
:double var = (Integer) spinSlider.getValue()
. - After
initPercentage()
:double var = (Integer) spinSlider.getValue()
.
- Returns:
- Current value
-
setValue
Sets the value.- Parameters:
value
- A new value
-
initInteger
public void initInteger(int value, int min, int max, int stepSize) Initializes this spin-slider to integers. Removed all listeners!- Parameters:
value
- Initial valuemin
- Minimum valuemax
- Maximum valuestepSize
- Spin step size
-
initDouble
public void initDouble(double value, double min, double max, int fractionDigits) Initializes this spin-slider to doubles. Removes all listeners!- Parameters:
value
- Initial valuemin
- Minimum valuemax
- Maximum valuefractionDigits
- precision of floating numbers, i.e., the number of digits allowed after the floating dot. Must be bigger than zero.
-
initPercentage
public void initPercentage(int value) Initializes this spin-slider to percents.- Parameters:
value
- Initial value between 0 and 100.
-
initPercentage
public void initPercentage(int value, int min, int max) Initializes this spin-slider to percents in given range.- Parameters:
value
- Initial value between 0 and 100.min
- min value in the range 0..100max
- max value in the range 0..100
-
setContinuousSync
public final void setContinuousSync(boolean continuousSync) Iftrue
, then the spinner is updated continuously during the slider move. Otherwise, the spinner remains unchanged until the mouse key is released.- Parameters:
continuousSync
- Whether to update the spinner continuously.
-
isContinuousSync
public boolean isContinuousSync()Iftrue
, then the spinner is updated continuously during the slider move. Otherwise, the spinner remains unchanged until the mouse key releases.- Returns:
true
if the slider and the spinner are synchronized continuously.
-
addSpinnerListener
Be informed when the spinner's value changes. See alsosetContinuousSync(boolean)
. Event's source is set toJSpinner
. For the double type of the spin-slider, it isDoubleSpinner
- Parameters:
listener
- the action listener to be added
-
addSliderListener
Be informed when the slider changes. See alsosetContinuousSync(boolean)
. Event's source is set toJSlider
- Parameters:
listener
- the action listener to be added
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classJComponent
-
getSpinner
-
getSlider
-
initComponents
protected final void initComponents() -
setSliderSize
public void setSliderSize(int size) Sets the width of slider.- Parameters:
size
- slider width
-