The moose likes Swing / AWT / SWT and the fly likes JScrollBar and JButton display problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollBar and JButton display problems" Watch "JScrollBar and JButton display problems" New topic

JScrollBar and JButton display problems

Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
Here is the code I have:

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.
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
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?
Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
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.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
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.
I agree. Here's the link:
subject: JScrollBar and JButton display problems
It's not a secret anymore!