My intent is to put the button on top of the scroll bar (inside another JPanel), but to my dismay I cannot get the scroll bar or the button to display with this scenario. Is there something inherantly wrong with this? Is there something special about the JScrollBar objec that I am not aware of? Any help would be appreciated. Shane
Hi Shane, I wrote a little test to see, if it works, what you want. This test worked fine, but it looks ugly because of the border layout.
What do you really want to do? Do you want to display page up and page down or something like this?
Joined: Aug 29, 2001
Yes, I am trying to get a beginning and end button to display somewhere in the vicinity of the scrollbar. My preference would be to have them incorporated into the scrollbar, but I haven't been successful in that endeavor either. Thanks for the help Rene.
JScrollBar seems not to offer any possibility to add components to it. I tried the simple add() inherited from Container but I am suspicious about these inherited methods that doesn't make big sense. it didn't work, anyway. the cleanest way to do this IMO would be: * look through the source code of JScrollBar, JScrollPane.ScrollBar and ScrollBarUI * create custom subclasses maybe faster is this way:
but consider that using JScrollPane is preferrable to JScrollBar as JScrollPane handles all the interaction stuff. creating your custom scrollbar that you could use inside a JScrollPane would spare you from implementing all this logic yourself. cheers