79
Java JScrollPane
A JscrollPane is used to make scrollable view of a component. When screen size is limited, we use a scroll pane to display a large component or a component whose size can change dynamically.
Constructors
Constructor | Purpose |
---|---|
JScrollPane() | It creates a scroll pane. The Component parameter, when present, sets the scroll pane’s client. The two int parameters, when present, set the vertical and horizontal scroll bar policies (respectively). |
JScrollPane(Component) | |
JScrollPane(int, int) | |
JScrollPane(Component, int, int) |
Useful Methods
Modifier | Method | Description |
---|---|---|
void | setColumnHeaderView(Component) | It sets the column header for the scroll pane. |
void | setRowHeaderView(Component) | It sets the row header for the scroll pane. |
void | setCorner(String, Component) | It sets or gets the specified corner. The int parameter specifies which corner and must be one of the following constants defined in ScrollPaneConstants: UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_LEADING_CORNER, LOWER_TRAILING_CORNER, UPPER_LEADING_CORNER, UPPER_TRAILING_CORNER. |
Component | getCorner(String) | |
void | setViewportView(Component) | Set the scroll pane’s client. |
JScrollPane Example
Output:
Next TopicJava JSplitPane