Package uk.ac.starlink.util.gui
Class ConstrainedViewportLayout
- java.lang.Object
-
- javax.swing.ViewportLayout
-
- uk.ac.starlink.util.gui.ConstrainedViewportLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager
,java.io.Serializable
public class ConstrainedViewportLayout extends javax.swing.ViewportLayout
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConstrainedViewportLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Dimension
preferredLayoutSize(java.awt.Container parent)
-