Javatpoint Logo
Javatpoint Logo


The layout manager is used by JScrollPane. JScrollPaneLayout is responsible for nine components: a viewport, two scrollbars, a row header, a column header, and four "corner" components.


ScrollPaneLayout(): The parameterless constructor is used to create a new ScrollPanelLayout.

Nested Class

Modifier and Type Class Description
static class ScrollPaneLayout.UIResource It is UI resource version of ScrollPaneLayout.

FieldScrollPanelLayout Field

Modifier and Type Field Description
protected JViewport colHead It is column header child.
protected JScrollBar hsb It is scrollpane's horizontal scrollbar child.
protected int hsbPolicy It displays policy for the horizontal scrollbar.
protected Component lowerLeft This displays the lower left corner.
protected Component lowerRight This displays in the lower right corner.
protected JViewport rowHead It is row header child.
protected Component upperLeft This component displays in the upper left corner.
protected Component upperRight This component displays in the upper right corner.
protected JViewport viewport It is scrollpane's viewport child.
protected JScrollBar vsb It is scrollpane's vertical scrollbar child.
protected int vsbPolicy It is the display policy for the vertical scrollbar.

ScrollPanelLayout Methods

Modifier and Type Method Description
void addLayoutComponent(String s, Component c) It adds the specified component to the layout.
protected Component addSingletonComponent(Component oldC, Component newC) It removes an existing component.
JViewport getColumnHeader() It returns the JViewport object that is the column header.
Component getCorner(String key) It returns the Component at the specified corner.
JScrollBar getHorizontalScrollBar() It returns the JScrollBar object that handles horizontal scrolling.
int getHorizontalScrollBarPolicy() It returns the horizontal scrollbar-display policy.
JViewport getRowHeader() It returns the JViewport object that is the row header.
JScrollBar getVerticalScrollBar() It returns the JScrollBar object that handles vertical scrolling.
int getVerticalScrollBarPolicy() It returns the vertical scrollbar-display policy.
JViewport getViewport() It returns the JViewport object that displays the scrollable contents.

Example: 1



Java Scrollpanellayout 1

Example: 2

The below Java program shows the usage of the ScrollPaneLayout by arranging the several components of JLabel in a JFrame,

whose instance class is named as "ScrollPaneDemo1". We create one JScrollPane component named "scrlpane".

Also, the JRadioButton and ButtonGroup are made. We set the visibility and size of the frame by using the setVisible() and setSize() methods, respectively.

The layout is being set by using the setLayout() method.



Java Scrollpanellayout
Next TopicJava Applet

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA