Class JScrollPane
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants
JScrollPane. Per
D_jscrollpane,
a thin delegating shell over the
SJScrollPane surrogate (extends Vaadin
Scroller). The scrollbar-policy ints field-shadow JDK-faithfully
(R_swing_is_truth store-then-drive); the setScrollDirection push to the surrogate is skipped when the current
viewport content is auto-scrolling (per
SD_sjscrollpane's
setContent override on the surrogate side), so user code reading back
its policy ints sees what it set even when wrapping a Grid / TextArea.
R_leaf_peer_lockdown-locked-down: no protected (Component peer) ctor — every
public ctor funnels through a private (SJScrollPane) ctor that
hard-codes the surrogate. JScrollPane is a leaf in
the public javax.swing.* hierarchy, so user-code subclasses
extend the public form and inherit the locked-in peer.
JViewport and JScrollBar are emulator-only shadow
JDK components (per D_viewport_scrollbar_shadows — Vaadin has no separate viewport object;
Vaadin Scroller's web component owns scrollbar rendering internally).
The shadow ports field-shadow their JDK state for round-trip but never
fire listeners (no Vaadin source for scroll-position events without a
custom DOM stack — R_match_swing_errors sub-bucket (a) until a migration target asks).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JViewportprotected JScrollBarprotected intprotected Componentprotected Componentprotected JViewportprotected Componentprotected Componentprotected JScrollBarprotected intprotected JViewportFields inherited from class JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, FILL_CHROME, FILL_DEFAULT, LEFT_ALIGNMENT, listenerList, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT -
Constructor Summary
ConstructorsConstructorDescriptionJScrollPane(int vsbPolicy, int hsbPolicy) JScrollPane(Component view) JScrollPane(Component view, int vsbPolicy, int hsbPolicy) -
Method Summary
Modifier and TypeMethodDescriptionintgetUI()intReturns theJViewportthat wraps the viewport view.The wrapped emulator component, ornullif none was set.booleanvoidsetColumnHeader(JViewport columnHeader) Stores the header viewport and fires"columnHeader"; nothing is rendered.voidsetColumnHeaderView(Component view) voidStores the corner and fires the key-named bound property; nothing is rendered — seesetColumnHeader(JViewport).voidReplace the horizontal scrollbar.voidsetHorizontalScrollBarPolicy(int policy) voidsetLayout(LayoutManager mgr) Accepts onlynull, throwing the JDK's ownClassCastExceptionand message for anything else —javax.swing.JScrollPane.setLayouttakes aScrollPaneLayoutornulland rejects the rest, so tolerating aBorderLayouthere would let code run that fails on the desktop (R_match_swing_errors).voidsetRowHeader(JViewport rowHeader) Stores and fires; nothing is rendered — seesetColumnHeader(JViewport).voidsetRowHeaderView(Component view) voidsetUI(ScrollPaneUI ui) voidvoidsetVerticalScrollBarPolicy(int policy) voidsetViewport(JViewport vp) Replace theJViewport.voidsetViewportBorder(Border viewportBorder) voidsetViewportView(Component view) Set the wrapped component.voidsetWheelScrollingEnabled(boolean handleWheel) voidupdateUI()protected voidsetViewportView attaches the view throughScroller.setContent(one-content-slot per SD_sjscrollpane), bypassingContainer.addImpl— the view never enters this JScrollPane'scomponentslist.Methods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, 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, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, addSlotChild, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, fireHierarchyEvent, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, peerContentElement, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeSlotChild, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validateMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, applyBackgroundToPeer, applyVisibleToPeer, awtListeners, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, defaultFillCssClass, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, fireComponentEvent, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isThemeDefault, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, suppressMouseBridge, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, withPeer, withPeerOnLiveUI
-
Field Details
-
verticalScrollBarPolicy
protected int verticalScrollBarPolicy -
horizontalScrollBarPolicy
protected int horizontalScrollBarPolicy -
viewport
-
horizontalScrollBar
-
verticalScrollBar
-
columnHeader
-
rowHeader
-
lowerLeft
-
lowerRight
-
upperLeft
-
upperRight
-
-
Constructor Details
-
JScrollPane
public JScrollPane() -
JScrollPane
-
JScrollPane
public JScrollPane(int vsbPolicy, int hsbPolicy) -
JScrollPane
-
-
Method Details
-
setViewportView
Set the wrapped component. Field-shadows the emulator-side reference, delegates toSJScrollPane.setContent(com.vaadin.flow.component.Component)(which applies the auto-scroll guard per SD_sjscrollpane), then re-pushes the scrollbar policy viapushPolicyToSurrogate()— the push is a no-op when content is auto-scrolling. -
getViewportView
The wrapped emulator component, ornullif none was set. -
getViewport
Returns theJViewportthat wraps the viewport view. Eagerly constructed in the ctor (added toContainer.componentsso the JDK tree shape round-trips). Per D_viewport_scrollbar_shadows, the JViewport is an emulator-only shadow JDK component — itsgetView/setViewround-trip the wrapped component, but viewport-position / extent-size APIs are round-trip-only (no Vaadin counterpart). -
setViewport
-
getHorizontalScrollBar
-
getVerticalScrollBar
-
setHorizontalScrollBar
Replace the horizontal scrollbar. JDK accepts user-supplied JScrollBar instances (rare; common in subclassed L&F-aware code). The old scrollbar is detached fromContainer.componentsand the new one inserted at the same JDK index (2 — after viewport and verticalScrollBar). No DOM impact: Vaadin Scroller renders its own scrollbar; the shadow's inert Div peer stays out of the peer DOM. -
setVerticalScrollBar
-
getVerticalScrollBarPolicy
public int getVerticalScrollBarPolicy() -
setVerticalScrollBarPolicy
public void setVerticalScrollBarPolicy(int policy) -
getHorizontalScrollBarPolicy
public int getHorizontalScrollBarPolicy() -
setHorizontalScrollBarPolicy
public void setHorizontalScrollBarPolicy(int policy) -
setViewportBorder
-
getViewportBorder
-
setColumnHeaderView
-
setRowHeaderView
-
setColumnHeader
Stores the header viewport and fires"columnHeader"; nothing is rendered. A VaadinScrollerhas one content slot and no header/corner grid, so the JDK'sadd(columnHeader, COLUMN_HEADER)has no target — the declined effect. State and notification are owed regardless (R_decline_effect_only, D_owed_events). -
getColumnHeader
-
setRowHeader
Stores and fires; nothing is rendered — seesetColumnHeader(JViewport). -
getRowHeader
-
setCorner
Stores the corner and fires the key-named bound property; nothing is rendered — seesetColumnHeader(JViewport). Invalid keys throwIllegalArgumentExceptionas in the JDK (R_match_swing_errors). -
getCorner
-
setWheelScrollingEnabled
public void setWheelScrollingEnabled(boolean handleWheel) -
isWheelScrollingEnabled
public boolean isWheelScrollingEnabled() -
setLayout
Accepts onlynull, throwing the JDK's ownClassCastExceptionand message for anything else —javax.swing.JScrollPane.setLayouttakes aScrollPaneLayoutornulland rejects the rest, so tolerating aBorderLayouthere would let code run that fails on the desktop (R_match_swing_errors).The JDK's accept-branch has nothing to accept, and costs nothing: SB-Emulators ports no
ScrollPaneLayout(its viewport / header / corner orchestration is R_vaadin_first drop-and-WARN per D_jscrollpane, the peer being one content slot), andjavax.swing.ScrollPaneLayoutis not avaadinx.awt.LayoutManager, so a migrator's surviving call would not compile either way.- Overrides:
setLayoutin classContainer- Parameters:
mgr- must benull- Throws:
ClassCastException- for any non-nullmanager
-
validateTree
protected void validateTree()setViewportView attaches the view throughScroller.setContent(one-content-slot per SD_sjscrollpane), bypassingContainer.addImpl— the view never enters this JScrollPane'scomponentslist. The inheritedContainer.validateTree()walkscomponentsonly, so without this override an inner panel created withnew JPanel()thensetLayout(new BoxLayout(...))keeps the FlowLayout CSS the SJPanel ctor wrote at construction time — its BoxLayout never gets a layoutContainer pass. Recursing into the viewportView closes that gap.- Overrides:
validateTreein classContainer
-
getUIClassID
- Overrides:
getUIClassIDin classJComponent
-
updateUI
public void updateUI()- Overrides:
updateUIin classJComponent
-
getUI
- Overrides:
getUIin classJComponent
-
setUI
-
getAccessibleContext
- Specified by:
getAccessibleContextin interfaceAccessible- Overrides:
getAccessibleContextin classComponent
-