Class SScrollbar
java.lang.Object
com.vaadin.flow.component.Component
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.html.RangeInput>, com.vaadin.flow.component.ClickNotifier<SScrollbar>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.html.RangeInput>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.html.RangeInput>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.html.RangeInput, Double>, Double>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.html.RangeInput, Double>, Double>, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.data.value.HasValueChangeMode, ComponentMixin, Serializable
public class SScrollbar
extends com.vaadin.flow.component.html.RangeInput
implements ComponentMixin, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.ClickNotifier<SScrollbar>, com.vaadin.flow.component.KeyNotifier
Surrogate for
AWT's
Scrollbar — the AWT 1.0 scrollbar, not
JScrollBar. Extends Vaadin RangeInput
(<input type=range>) directly (is-a) and picks up the AWT
Component API from ComponentMixin.
SScrollbar bar = new SScrollbar(Adjustable.HORIZONTAL, 0, 10, 0, 255);
bar.addValueChangeListener(e -> tint(e.getValue().intValue()));
bar.setValues(128, 10, 0, 255); // clamped, silent
It renders as a slider, not as a scrollbar
AWT paints a track, two end arrows, and a thumb whose length isvisibleAmount / (maximum - minimum). No HTML control has a
resizable thumb or end arrows, so this renders as a plain range slider:
functionally faithful (value, band, orientation, drag, keyboard, events),
visually a different widget. That trade is deliberate — AWT 1.0 had no
slider, so a Scrollbar was the zoom / volume / colour
knob, and that idiom reads correctly as a slider. The hand-rolled-scroller
idiom (a Scrollbar beside a Canvas) does not, and is
already out of scope via Canvas painting (R_match_swing_errors sub-bucket (b)).
Vertical is the default, and needs two properties
new Scrollbar() is vertical — unlike every Swing slider —
so vertical rendering is the common path, not a corner case.
RangeInput.setOrientation(RangeInput.Orientation) alone is not enough: it sets only the
pre-standardization recipe (appearance: slider-vertical, removed in
Chromium 132; writing-mode: bt-lr, never standardized) and on its
own renders a square blob in current Chromium. applyOrientationCss(boolean)
adds the standardized writing-mode: vertical-lr, which is what
actually works — and, unlike the transform: rotate(-90deg) that
SJSlider uses, it changes the element's layout box, so a
vertical bar in BorderLayout.EAST gets a region its own width
rather than one sized for a wide short control. It also puts the minimum at
the top, which is AWT's own convention.
The value band is not [minimum, maximum]
AWT's reachable band is[minimum, maximum - visibleAmount], so the
peer's max carries maximum - visibleAmount and
getMaximum() reconstructs by adding visibleAmount back.
visibleAmount is therefore not a shadow field: it genuinely drives
the peer's max (SD_sscrollbar records the choice — storing maximum
and deriving visibleAmount would be symmetric).
No listener list here
AdjustmentEvent's source parameter is typed
Adjustable, and this class cannot implement Adjustable —
int getValue() and int getOrientation() both clash
irreconcilably with Vaadin's Double getValue() /
Orientation getOrientation(). So the surrogate could not construct
an event naming itself, and the fan-out lives on the emulator
vaadinx.awt.Scrollbar, which bridges from Vaadin's
addValueChangeListener. This is the one structural departure from
SButton / SLabel (SD_sscrollbar).
step stays 1
AWT's unitIncrement is only an arrow-key delta over a continuous
value space; HTML's step quantizes the whole value space. Writing
unitIncrement into step would make values unreachable
(with step=16 on a 0–90 band, value=37 reads back 32 and
the band's top 90 reads back 80) and would manufacture value-change events
out of the browser's rounding of the migrator's own writes. So
unitIncrement is stored and inert — R_match_swing_errors sub-bucket (c), on a
property the JDK itself documents as ignorable by the underlying control.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.html.RangeInput
com.vaadin.flow.component.html.RangeInput.OrientationNested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E> -
Field Summary
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionSScrollbar(int orientation) SScrollbar(int orientation, int value, int visible, int minimum, int maximum) -
Method Summary
Modifier and TypeMethodDescriptionintintintintintintbooleanintprotected StringAWT'sScrollbar.paramStringtail.voidsetAwtOrientation(int orientation) voidsetBlockIncrement(int blockIncrement) voidsetEnabled(boolean enabled) Fires SD_auto_pce's auto-PCE, then letsRangeInputdo its own work.voidsetIntValue(int value) voidsetMaximum(int maximum) voidsetMinimum(int minimum) voidsetUnitIncrement(int unitIncrement) voidsetValueIsAdjusting(boolean valueIsAdjusting) voidsetValues(int value, int visible, int minimum, int maximum) AWT's single clamping funnel:setValue,setMinimum,setMaximumandsetVisibleAmountall route here, so the DOM can never hold an out-of-band value.voidsetVisibleAmount(int visible) Sets the span AWT would paint as the thumb's length.Methods inherited from class com.vaadin.flow.component.html.RangeInput
bindMax, bindMin, getMax, getMin, getOrientation, getStep, getValueChangeMode, getValueChangeTimeout, isEnabled, isReadOnly, setMax, setMin, setOrientation, setReadOnly, setStep, setValueChangeMode, setValueChangeTimeoutMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setToolTipText, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isRequiredIndicatorVisible, setRequiredIndicatorVisibleMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
SScrollbar
public SScrollbar() -
SScrollbar
public SScrollbar(int orientation) -
SScrollbar
public SScrollbar(int orientation, int value, int visible, int minimum, int maximum) - Parameters:
orientation-Adjustable.HORIZONTALorAdjustable.VERTICAL—Adjustable.NO_ORIENTATIONis not legal here, matching AWT- Throws:
IllegalArgumentException- on any other value, with AWT's own message, thrown before any peer write so no half-built scrollbar escapes
-
-
Method Details
-
setValues
public void setValues(int value, int visible, int minimum, int maximum) AWT's single clamping funnel:setValue,setMinimum,setMaximumandsetVisibleAmountall route here, so the DOM can never hold an out-of-band value. Never throws — every int,Integer.MIN_VALUEandInteger.MAX_VALUEincluded, is clamped.The JDK's five steps, verbatim: pin
minimumbelowMAX_VALUE; forcemaximum > minimum; cap the span atMAX_VALUE; clampvisibleinto[1, span]; clampvalueinto[minimum, maximum - visible]. -
getIntValue
public int getIntValue()- Returns:
- the current value; int-exact across the whole reachable band
-
setIntValue
public void setIntValue(int value) -
getMinimum
public int getMinimum() -
setMinimum
public void setMinimum(int minimum) -
getMaximum
public int getMaximum()- Returns:
peer.max + visibleAmount— the band's top ismax
-
setMaximum
public void setMaximum(int maximum) -
getVisibleAmount
public int getVisibleAmount() -
setVisibleAmount
public void setVisibleAmount(int visible) Sets the span AWT would paint as the thumb's length.- Parameters:
visible- functional — it sets the peer'smaxand so the reachable band — but invisible: no HTML control has a resizable thumb (R_match_swing_errors sub-bucket (c), and not blocked-upstream, since the ceiling is the HTML control rather than a missing Vaadin API)
-
getAwtOrientation
public int getAwtOrientation()- Returns:
Adjustable.HORIZONTALorAdjustable.VERTICAL
-
setAwtOrientation
public void setAwtOrientation(int orientation) - Parameters:
orientation- AWT's early-return on an unchanged value comes first, so an illegal int that happens to equal the current orientation cannot throw — it cannot be reached- Throws:
IllegalArgumentException- with AWT's own message otherwise
-
getUnitIncrement
public int getUnitIncrement() -
setUnitIncrement
public void setUnitIncrement(int unitIncrement) - Parameters:
unitIncrement- clamped up to 1, as AWT does. Stored and inert: the only browser lever isstep, which would quantize the whole value space rather than just the arrow delta (R_match_swing_errors(c); see the class javadoc)
-
getBlockIncrement
public int getBlockIncrement() -
setBlockIncrement
public void setBlockIncrement(int blockIncrement) - Parameters:
blockIncrement- clamped up to 1, as AWT does. Stored and inert: PageUp/PageDown on<input type=range>move by a browser-chosen amount that is not settable (R_match_swing_errors(c))
-
getValueIsAdjusting
public boolean getValueIsAdjusting()- Returns:
- true while a browser drag is in flight
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean valueIsAdjusting) - Parameters:
valueIsAdjusting- advisory — the browser overwrites it on the next gesture (R_match_swing_errors(c)). Would become blocked-upstream if Vaadin exposed a pointer-down/up signal onRangeInput
-
setEnabled
public void setEnabled(boolean enabled) Fires SD_auto_pce's auto-PCE, then letsRangeInputdo its own work.Not
ComponentMixin.super.setEnabled(...)— the SD_sbutton redirect is wrong on this host.RangeInputkeeps its ownenabledfield and reconciles it withreadOnly; routing past that leaves the field stale, soisEnabled()would disagree with the DOM.- Specified by:
setEnabledin interfaceComponentMixin- Specified by:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled- Overrides:
setEnabledin classcom.vaadin.flow.component.html.RangeInput
-
paramString
AWT'sScrollbar.paramStringtail. Note,vert/,horzcarry no=. -
getAccessibleContext
-