java.awt.LayoutManager
, java.io.Serializable
public class ConstrainedViewportLayout
extends javax.swing.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 | Description |
---|---|
ConstrainedViewportLayout() |
Modifier and Type | Method | Description |
---|---|---|
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent) |
Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.