public class ScrollPaneLayout extends ScrollPaneLayout implements Mergeable, Cloneable
ScrollPaneLayout
used within JScrollPane
to layout components.
It allows deeper customization of scroll bar placement and a few enhancements to default calculations.
Note: The only reason why this layout is based on ScrollPaneLayout
is because
JScrollPane.setLayout(LayoutManager)
method accepts only ScrollPaneLayout
-based layouts and nothing else.
Unfortunately there is no good workaround so it have been used as a base for this layout for the time being.
All unserializable fields have been forcefully emptied and omitted for XStream in StyleManager
.Modifier and Type | Class and Description |
---|---|
static class |
ScrollPaneLayout.UIResource
The UI resource version of
ScrollPaneLayout . |
Modifier and Type | Field and Description |
---|---|
protected static ScrollBarSettings |
DEFAULT_SCROLL_BAR_SETTINGS
Default
ScrollBarSettings for vertical and horizontal scroll bars. |
protected ScrollBarSettings |
hpos
ScrollBarSettings for horizontal scroll bar. |
protected ScrollBarSettings |
vpos
ScrollBarSettings for vertical scroll bar. |
colHead, hsb, hsbPolicy, lowerLeft, lowerRight, rowHead, upperLeft, upperRight, viewport, vsb, vsbPolicy
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 and Description |
---|
ScrollPaneLayout() |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(String s,
Component c) |
protected void |
adjustForHSB(JScrollBar hsb,
boolean needed,
Rectangle view,
Rectangle scroll,
Insets viewInsets)
Adjusts the
Rectangle available based on if the horizontal scrollbar is needed (wantsHSB ). |
protected void |
adjustForVSB(JScrollBar vsb,
boolean needed,
Rectangle view,
Rectangle scroll,
Insets viewInsets,
boolean leftToRight)
Adjusts the
Rectangle available based on if the vertical scrollbar is needed (wantsVSB ). |
ScrollBarSettings |
getHorizontalScrollBarPosition()
Returns
ScrollBarSettings for horizontal scroll bar. |
ScrollBarSettings |
getVerticalScrollBarPosition()
Returns
ScrollBarSettings for vertical scroll bar. |
void |
layoutContainer(Container container) |
Dimension |
minimumLayoutSize(Container container)
The minimum size of a
JScrollPane is the size of the insets plus minimum size of the viewport, plus the scrollpane's
viewportBorder insets, plus the minimum size of the visible headers, plus the minimum size of the scrollbars whose displayPolicy
isn't ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER or ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER . |
Dimension |
preferredLayoutSize(Container container) |
void |
removeLayoutComponent(Component c) |
void |
setHorizontalScrollBarPosition(ScrollBarSettings position)
Sets
ScrollBarSettings for horizontal scroll bar. |
void |
setVerticalScrollBarPosition(ScrollBarSettings position)
Sets
ScrollBarSettings for vertical scroll bar. |
void |
syncWithScrollPane(JScrollPane scrollPane) |
addSingletonComponent, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorderBounds, setHorizontalScrollBarPolicy, setVerticalScrollBarPolicy
protected static final ScrollBarSettings DEFAULT_SCROLL_BAR_SETTINGS
ScrollBarSettings
for vertical and horizontal scroll bars.protected ScrollBarSettings vpos
ScrollBarSettings
for vertical scroll bar.
These settings must always be specified otherwise you will have NullPointerException
.protected ScrollBarSettings hpos
ScrollBarSettings
for horizontal scroll bar.
These settings must always be specified otherwise you will have NullPointerException
.public ScrollBarSettings getVerticalScrollBarPosition()
ScrollBarSettings
for vertical scroll bar.ScrollBarSettings
for vertical scroll barpublic void setVerticalScrollBarPosition(ScrollBarSettings position)
ScrollBarSettings
for vertical scroll bar.position
- ScrollBarSettings
for vertical scroll barpublic ScrollBarSettings getHorizontalScrollBarPosition()
ScrollBarSettings
for horizontal scroll bar.ScrollBarSettings
for horizontal scroll barpublic void setHorizontalScrollBarPosition(ScrollBarSettings position)
ScrollBarSettings
for horizontal scroll bar.position
- ScrollBarSettings
for horizontal scroll barpublic void addLayoutComponent(String s, Component c)
addLayoutComponent
in interface LayoutManager
addLayoutComponent
in class ScrollPaneLayout
public void removeLayoutComponent(Component c)
removeLayoutComponent
in interface LayoutManager
removeLayoutComponent
in class ScrollPaneLayout
public void syncWithScrollPane(JScrollPane scrollPane)
syncWithScrollPane
in class ScrollPaneLayout
public void layoutContainer(Container container)
layoutContainer
in interface LayoutManager
layoutContainer
in class ScrollPaneLayout
protected void adjustForVSB(JScrollBar vsb, boolean needed, Rectangle view, Rectangle scroll, Insets viewInsets, boolean leftToRight)
Rectangle
available
based on if the vertical scrollbar is needed (wantsVSB
).
The location of the vsb is updated in vsbR
, and the viewport border insets (vpbInsets
) are used to offset the vsb.
This is only called when wantsVSB
has changed, eg you shouldn't invoke adjustForVSB(true) twice.vsb
- vertical scroll barneeded
- whether or not vertical scroll bar is neededview
- space available for viewscroll
- vertical scroll bar boundsviewInsets
- viewport border insetsleftToRight
- component orientationprotected void adjustForHSB(JScrollBar hsb, boolean needed, Rectangle view, Rectangle scroll, Insets viewInsets)
Rectangle
available
based on if the horizontal scrollbar is needed (wantsHSB
).
The location of the hsb is updated in hsbR
, and the viewport border insets (vpbInsets
) are used to offset the hsb.
This is only called when wantsHSB
has changed, eg you shouldn't invoked adjustForHSB(true) twice.hsb
- horizontal scroll barneeded
- whether or not horizontal scroll bar is neededview
- space available for viewscroll
- horizontal scroll bar boundsviewInsets
- viewport border insetspublic Dimension preferredLayoutSize(Container container)
preferredLayoutSize
in interface LayoutManager
preferredLayoutSize
in class ScrollPaneLayout
public Dimension minimumLayoutSize(Container container)
JScrollPane
is the size of the insets plus minimum size of the viewport, plus the scrollpane's
viewportBorder insets, plus the minimum size of the visible headers, plus the minimum size of the scrollbars whose displayPolicy
isn't ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
or ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
.minimumLayoutSize
in interface LayoutManager
minimumLayoutSize
in class ScrollPaneLayout
container
- the Container
that will be laid outDimension
object specifying the minimum sizeCopyright © 2020. All rights reserved.