Class Scrollbar
java.lang.Object
vaadinx.awt.Component
vaadinx.awt.Scrollbar
- All Implemented Interfaces:
Adjustable, ImageObserver, MenuContainer, Serializable, Accessible
Emulator for
Scrollbar — the AWT 1.0 scrollbar, not
JScrollBar. Holds the JDK's value model itself, so
every getter answers on any thread without reaching the
SScrollbar peer, which renders it.
The fan-out lives here too: the peer cannot hold the
Adjustable identity that
AdjustmentEvent demands of its source.
Scrollbar zoom = new Scrollbar(Scrollbar.HORIZONTAL, 0, 10, 0, 255);
zoom.addAdjustmentListener(e -> setZoom(e.getValue()));
zoom.setValue(128); // silent: no AdjustmentEvent, as in AWT
It is a value control, and it renders as a slider
AWT's scroll pane does not use this class —ScrollPane
hands out ScrollPaneAdjustable, a different final class —
so a Scrollbar exists only because migrated code constructed one.
AWT 1.0 had no slider, so that code is overwhelmingly using it as a zoom /
volume / colour knob, which is why the peer is a range slider rather than
the inert Div vaadinx.swing.JScrollBar peers on (D_viewport_scrollbar_shadows's
"it is chrome the scroll container renders for us" is true in Swing and
false here). The visual cost — no end arrows, and a thumb whose length
cannot carry visibleAmount — is R_match_swing_errors sub-bucket (c); see
SScrollbar.
Only the browser posts events
setValue and setValues fire nothing: their javadoc says so
outright, and the JDK source fires only an accessibility PCE. That inverts
JScrollBar, whose BoundedRangeModel fires on
every write, and it means no preventPeerEvents flag is needed here —
a server-side push is precisely the case AWT stays silent for, so the
bridge gates on isFromClient() instead (the SCheckbox
precedent).
A browser gesture reaches the model through the public methods, as a
platform peer's does: a drag step calls setValueIsAdjusting(boolean) and
setValue(int) before the event posts, so a migrator's setValue
override sees the user's traffic too. Every browser-sourced event reports
AdjustmentEvent.TRACK: nothing distinguishes an
end-arrow click from a track click from a keypress server-side, and a wrong
adjustment type is worse than a consistently honest one.
Leaf lock-down (R_leaf_peer_lockdown)
Nothing injava.awt extends Scrollbar
(javax.swing.JScrollBar descends from JComponent;
ScrollPaneAdjustable is final and merely implements
Adjustable), so there is no protected (Component peer) ctor
and every instance peers over an SScrollbar. Both orientations ride
one peer type, so no D_frame_strategy-style peer dispatch is needed either.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int0 — the same value asAdjustable.HORIZONTAL.static final int1 — the same value asAdjustable.VERTICAL.Fields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, FILL_CHROME, FILL_DEFAULT, LEFT_ALIGNMENT, listenerList, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface Adjustable
NO_ORIENTATIONFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionA vertical scrollbar, value 0, visibleAmount 10, band 0–100.Scrollbar(int orientation) Scrollbar(int orientation, int value, int visible, int minimum, int maximum) Seeds the value model throughsetValues(int, int, int, int), as the JDK does, so a subclass's override runs from the constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidintintDeprecated.intintintintDeprecated.as of JDK 1.1, replaced bygetBlockIncrement()intintgetValue()booleanintDeprecated.as of JDK 1.1, replaced bygetVisibleAmount()intprotected Stringprotected voidThe single funnel every adjustment reaches the listeners through — both the peer bridge and a user-codeprocessEventcall.protected voidvoidvoidsetBlockIncrement(int v) voidsetLineIncrement(int v) Deprecated.as of JDK 1.1, replaced bysetUnitIncrement(int)voidsetMaximum(int maximum) The rewritten minimum is stored straight into the field, as the JDK does, so it holds even when an overridingsetValues(int, int, int, int)does not call super.voidsetMinimum(int minimum) voidsetOrientation(int orientation) voidsetPageIncrement(int v) Deprecated.as of JDK 1.1, replaced bysetBlockIncrement(int)voidsetUnitIncrement(int v) voidsetValue(int value) Routes throughsetValues(int, int, int, int)rather than writing the peer directly —setValuesis the JDK's single funnel and the natural override point for a migrator tightening clamping, so a direct write here would leave that override never running (R_no_vaadin_in_api limb 2).voidsetValueIsAdjusting(boolean b) voidsetValues(int value, int visible, int minimum, int maximum) The single clamping funnel every value mutator routes through — and the override point AWT subclasses use to tighten clamping, so it must stay the only path to the peer.voidsetVisibleAmount(int visible) Methods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyBackgroundToPeer, applyComponentOrientation, applyVisibleToPeer, areFocusTraversalKeysSet, awtListeners, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, defaultFillCssClass, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, fireComponentEvent, fireHierarchyEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isThemeDefault, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, suppressMouseBridge, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate, withPeer, withPeerOnLiveUI
-
Field Details
-
HORIZONTAL
-
VERTICAL
-
-
Constructor Details
-
Scrollbar
A vertical scrollbar, value 0, visibleAmount 10, band 0–100.- Throws:
HeadlessException
-
Scrollbar
- Throws:
HeadlessException
-
Scrollbar
public Scrollbar(int orientation, int value, int visible, int minimum, int maximum) throws HeadlessException Seeds the value model throughsetValues(int, int, int, int), as the JDK does, so a subclass's override runs from the constructor.- Parameters:
orientation-HORIZONTALorVERTICAL;Adjustable.NO_ORIENTATIONis not legal, even though it is a constant on the interface this class implements- Throws:
IllegalArgumentException- on any other value — out ofsuper(...), so no half-builtScrollbarescapesHeadlessException- never in practice; the clause is kept for signature fidelity, matchingFrame
-
-
Method Details
-
addNotify
-
getOrientation
public int getOrientation()- Specified by:
getOrientationin interfaceAdjustable
-
setOrientation
public void setOrientation(int orientation) - Parameters:
orientation- an unchanged value returns early before the legality check, as in AWT, so an illegal int equal to the current orientation cannot be reached- Throws:
IllegalArgumentException-"illegal scrollbar orientation"
-
getValue
public int getValue()- Specified by:
getValuein interfaceAdjustable
-
setValue
public void setValue(int value) Routes throughsetValues(int, int, int, int)rather than writing the peer directly —setValuesis the JDK's single funnel and the natural override point for a migrator tightening clamping, so a direct write here would leave that override never running (R_no_vaadin_in_api limb 2).- Specified by:
setValuein interfaceAdjustable- Parameters:
value- clamped into[minimum, maximum - visibleAmount]; fires noAdjustmentEvent
-
getMinimum
public int getMinimum()- Specified by:
getMinimumin interfaceAdjustable
-
setMinimum
public void setMinimum(int minimum) - Specified by:
setMinimumin interfaceAdjustable- Parameters:
minimum- seesetValue(int)on thesetValuesfunnel
-
getMaximum
public int getMaximum()- Specified by:
getMaximumin interfaceAdjustable
-
setMaximum
public void setMaximum(int maximum) The rewritten minimum is stored straight into the field, as the JDK does, so it holds even when an overridingsetValues(int, int, int, int)does not call super.- Specified by:
setMaximumin interfaceAdjustable- Parameters:
maximum-Integer.MIN_VALUEis nudged up by one, and aminimumthat would meet or pass the new maximum is rewritten before the funnel runs — both are AWT's own pre-steps, outsidesetValues
-
getVisibleAmount
public int getVisibleAmount()- Specified by:
getVisibleAmountin interfaceAdjustable
-
setVisibleAmount
public void setVisibleAmount(int visible) - Specified by:
setVisibleAmountin interfaceAdjustable- Parameters:
visible- seesetValue(int)on thesetValuesfunnel
-
setValues
public void setValues(int value, int visible, int minimum, int maximum) The single clamping funnel every value mutator routes through — and the override point AWT subclasses use to tighten clamping, so it must stay the only path to the peer.Never throws: every int,
Integer.MIN_VALUEandInteger.MAX_VALUEincluded, is clamped. Fires noAdjustmentEvent. -
getUnitIncrement
public int getUnitIncrement()- Specified by:
getUnitIncrementin interfaceAdjustable
-
setUnitIncrement
public void setUnitIncrement(int v) - Specified by:
setUnitIncrementin interfaceAdjustable- Parameters:
v- clamped up to 1, as AWT does. Stored but inert: the only browser lever is the peer'sstep, which would quantize the whole value space rather than just the arrow delta (R_match_swing_errors sub-bucket (c); rationale inSScrollbar)
-
getBlockIncrement
public int getBlockIncrement()- Specified by:
getBlockIncrementin interfaceAdjustable
-
setBlockIncrement
public void setBlockIncrement(int v) - Specified by:
setBlockIncrementin interfaceAdjustable- Parameters:
v- clamped up to 1, as AWT does. Stored but inert — PageUp / PageDown on<input type=range>move by a browser-chosen amount that is not settable (R_match_swing_errors sub-bucket (c))
-
getVisible
Deprecated.as of JDK 1.1, replaced bygetVisibleAmount() -
setLineIncrement
Deprecated.as of JDK 1.1, replaced bysetUnitIncrement(int) -
getLineIncrement
Deprecated.as of JDK 1.1, replaced bygetUnitIncrement() -
setPageIncrement
Deprecated.as of JDK 1.1, replaced bysetBlockIncrement(int) -
getPageIncrement
Deprecated.as of JDK 1.1, replaced bygetBlockIncrement() -
getValueIsAdjusting
public boolean getValueIsAdjusting()- Returns:
- true while a browser drag is in flight, or after a
setValueIsAdjusting(true)
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean b) - Parameters:
b- advisory on the peer — the browser overwrites its flag on the next gesture (R_match_swing_errors sub-bucket (c)), and the drag writes this one back through here
-
addAdjustmentListener
- Specified by:
addAdjustmentListenerin interfaceAdjustable- Parameters:
l- null is a documented no-op, not an NPE
-
removeAdjustmentListener
- Specified by:
removeAdjustmentListenerin interfaceAdjustable- Parameters:
l- null is a documented no-op
-
getAdjustmentListeners
-
processEvent
- Overrides:
processEventin classComponent
-
processAdjustmentEvent
The single funnel every adjustment reaches the listeners through — both the peer bridge and a user-codeprocessEventcall. AWT subclasses override this (calling super) to intercept adjustments wholesale, so it must stay the only dispatch path.- Parameters:
e- null is a no-op; the JDK calls the behaviour "unspecified" there, and D_awt_button settled that as no-op rather than NPE
-
paramString
- Overrides:
paramStringin classComponent
-
getAccessibleContext
- Specified by:
getAccessibleContextin interfaceAccessible- Overrides:
getAccessibleContextin classComponent
-
getUnitIncrement()