JScrollPane – Other


Set Viewport Border

jScrollPane1.setViewportBorder(new LineBorder(Color.BLACK,5));
jScrollPane1.revalidate();
Reset:
    jScrollPane1.setViewportBorder(null);
    jScrollPane1.revalidate();

Enable Mouse Wheel Scrolling

jScrollPane1.setWheelScrollingEnabled(true);
Reset:
    jScrollPane1.setWheelScrollingEnabled(true); //defzult value

Set Orientation

jScrollPane1.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

Note:
    ComponentOrientation.LEFT_TO_RIGHT
    ComponentOrientation.RIGHT_TO_LEFT
    ComponentOrientation.UNKNOWN      //default value

New VIewport

jScrollPane1.setViewport(new JViewport());

New Row Header

jScrollPane1.setRowHeader(new JViewport());



New Column Header

jScrollPane1.setColumnHeader(new JViewport());


New Verical Scroll Bar

jScrollPane1.setVerticalScrollBar(new JScrollBar());



New Vertical Scroll Bar Model

if (jScrollPane1.getVerticalScrollBar() != null) {
    jScrollPane1.getVerticalScrollBar().setModel(new DefaultBoundedRangeModel());
}

New Horizontal Scroll Bar

jScrollPane1.setHorizontalScrollBar(new JScrollBar());


New Horizontal Scroll Bar Model

if (jScrollPane1.getHorizontalScrollBar() != null) {
    jScrollPane1.getHorizontalScrollBar().setModel(new DefaultBoundedRangeModel());
}