Horizontal JScrollBar at the top of a JScrollPane

JScrollPane, by default places the Hoorizontal JScrollBar at the bottom of the pane.How can I place it at the top ?
[129 byte] By [carlosmohea] at [2007-11-26 19:42:13]
# 1
I think the setCorner() method will do what you want: http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#decorations
zadoka at 2007-7-9 22:24:04 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks for the hint, I appreciate it.

I have read the documentation concerning setCorner() together with the page you pointed to.

However setCorner() will place Components on any of the four corners of the JScrollPane, and what I need it to place the horizontal bar at the top of it.

If you look at the picture in:

http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#decorations

you will see the horizontal JScrollBar at the bottom of the pane, I would like to lift it up to be placed right underneath the area called "custom row header"

Any Ideas ?

carlosmohea at 2007-7-9 22:24:04 > top of Java-index,Desktop,Core GUI APIs...
# 3

JScrollPane uses a ScrollPaneLayout to position its child components, and in particular the viewport and the scroll bars. If you want to change how it positions the horizontal scroll bar, the only way I see is to implement a subclass of ScrollPaneLayout, overriding its layoutContainer() method. Once you have implemented that, create an instance and use it as the layout manager:JScrollPane jsp = new JScrollPane();

jsp.setLayout(new MyVeryOwnScrollPaneLayout());

I imagine you were hoping for a simpler solution, but I don't have one for you. Maybe someone else does...

Geoff

glevnera at 2007-7-9 22:24:04 > top of Java-index,Desktop,Core GUI APIs...