ScrollPaneLayout

ScrollPaneLayout

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

Nested Class

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

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.

Useful 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. import javax.swing.ImageIcon;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;
  4. import javax.swing.JScrollPane;
  5. public class ScrollPaneDemo extends JFrame
  6. {
  7. public ScrollPaneDemo() {
  8. super(“ScrollPane Demo”);
  9. ImageIcon img = new ImageIcon(“child.png”);
  10. JScrollPane png = new JScrollPane(new JLabel(img));
  11. getContentPane().add(png);
  12. setSize(300,250);
  13. setVisible(true);
  14. }
  15. public static void main(String[] args) {
  16. new ScrollPaneDemo();
  17. }
  18. }

Output:

Java Scrollpanellayout 1

Next TopicJava Applet

 

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

ScrollPaneLayout The layout manager used by JScrollPane. JScrollPaneLayout is responsible for nine components: a viewport, two scrollbars, a row header, a column header, and four “corner” components. Nested Class Modifier and Type Class Description static class ScrollPaneLayout.UIResource It is UI resource version of ScrollPaneLayout. Field Modifier and Type Field Description protected JViewport colHead It is […]

Tags:

....
...