Hi.
I'm trying to modify JScrollPane to have right vertical scroll to have custom components on top of scroll and at the bottom.
I've modified ScrollPaneLayout class to achieve that. I did the following:
import java.awt.Container;
import java.awt.Rectangle;
import javax.swing.ScrollPaneLayout;
public class MyScrollPaneLayout extends ScrollPaneLayout {
public void layoutContainer(Container parent) {
super.layoutContainer(parent);
Rectangle vsb_bounds = vsb.getBounds();
vsb_bounds.y = vsb_bounds.y + 16;
vsb_bounds.height = vsb_bounds.height - (16 * 4);
vsb.setBounds(vsb_bounds);
Rectangle upperRight_bounds = upperRight.getBounds();
upperRight_bounds.height = upperRight_bounds.height + 16;
upperRight.setBounds(upperRight_bounds);
Rectangle lowerRight_bounds = lowerRight.getBounds();
lowerRight_bounds.y = lowerRight_bounds.y - (16 * 3);
lowerRight_bounds.height = lowerRight_bounds.height + (16 * 3);
lowerRight.setBounds(lowerRight_bounds);
}
}
and then in my main code:
scroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, component1);
scroll.setCorner(JScrollPane.LOWER_RIGHT_CORNER, component2);
MyScrollPaneLayout scroll_layout = new MyScrollPaneLayout();
scroll.setLayout(scroll_layout);
scroll_layout.syncWithScrollPane(scroll);
I have small problem with this code. component2 is ONLY visible when lower horizontal scroll bar is visible. I need both component1 and componet2 visible even when horizontal bar is not visible.
Can somebody help me with this?