Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollBar and JButton display problems

 
Shane Roylance
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Shane
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic