Package uk.ac.starlink.util.gui
Class ConstrainedViewportLayout
java.lang.Object
javax.swing.ViewportLayout
uk.ac.starlink.util.gui.ConstrainedViewportLayout
- All Implemented Interfaces:
LayoutManager
,Serializable
This is a tweaked ViewportLayout implementation to work round an issue
with scrollbar positioning.
The problem arises when you have scrollbar policies VERTICAL_SCROLLBAR_AS_NEEDED and HORIZONTAL_SCROLLBAR_NEVER. When the vertical scrollbar appears, it is not accounted for in the preferred size of the scrollpane component. This can, depending on the parent layout, lead to the right hand side of the view component being obscured by the scrollbar.
You can apparently work round the problem with this class, by doing
scrollPane.getViewport().setLayout(new ConstraintedViewportLayout());I found this solution at stack overflow. I don't really understand why it works.
- Since:
- 27 Nov 2017
- Author:
- Mark Taylor, https://stackoverflow.com/users/463018/meyertee
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class javax.swing.ViewportLayout
addLayoutComponent, layoutContainer, minimumLayoutSize, removeLayoutComponent
-
Constructor Details
-
ConstrainedViewportLayout
public ConstrainedViewportLayout()
-
-
Method Details
-
preferredLayoutSize
- Specified by:
preferredLayoutSize
in interfaceLayoutManager
- Overrides:
preferredLayoutSize
in classViewportLayout
-