Class SScrollbar

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.html.RangeInput, Double>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.html.RangeInput, Double>
com.vaadin.flow.component.html.RangeInput
com.vaadin.swingbridge.surrogates.SScrollbar
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 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 is visibleAmount / (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:
  • 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.HORIZONTAL or Adjustable.VERTICAL — Adjustable.NO_ORIENTATION is 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, setMaximum and setVisibleAmount all route here, so the DOM can never hold an out-of-band value. Never throws — every int, Integer.MIN_VALUE and Integer.MAX_VALUE included, is clamped.

      The JDK's five steps, verbatim: pin minimum below MAX_VALUE; force maximum > minimum; cap the span at MAX_VALUE; clamp visible into [1, span]; clamp value into [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 is max
    • 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's max and 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.HORIZONTAL or Adjustable.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 is step, 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 on RangeInput
    • setEnabled

      public void setEnabled(boolean enabled)
      Fires SD_auto_pce's auto-PCE, then lets RangeInput do its own work.

      Not ComponentMixin.super.setEnabled(...) — the SD_sbutton redirect is wrong on this host. RangeInput keeps its own enabled field and reconciles it with readOnly; routing past that leaves the field stale, so isEnabled() would disagree with the DOM.

      Specified by:
      setEnabled in interface ComponentMixin
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
      Overrides:
      setEnabled in class com.vaadin.flow.component.html.RangeInput
    • paramString

      protected String paramString()
      AWT's Scrollbar.paramString tail. Note ,vert / ,horz carry no =.
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()