public class ConstrainedViewportLayout extends ViewportLayout
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.
Constructor and Description |
---|
ConstrainedViewportLayout() |
Modifier and Type | Method and Description |
---|---|
Dimension |
preferredLayoutSize(Container parent) |
addLayoutComponent, layoutContainer, minimumLayoutSize, removeLayoutComponent
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
preferredLayoutSize
in class ViewportLayout
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.