Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drawing my own ScrollBar

 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application where we parse data from a file and then display it in a JTable within a JScrollPane. I want to "draw" an extra two buttons on the ScrollBar, one on the very top above the existing top button and one on the very bottom below the existing bottom button. These buttons would basically be used as "page up" and "page down" buttons, the bottom one parsing the next xx entries in the file and adding them to the bottom of the table when the user is already viewing the last entry. I'm not sure how to go about this.

I already have routines in place to handle the page up and page down behavior but what I don't know how to do is draw these buttons. I've used paint() before for things like drawing images and shapes but I have no idea how to go about drawing these simple little buttons, there's the L&F to deal with and everything. How the heck do I go about this? Can I subclass JScrollBar and just draw an extra button on top and the bottom? What the heck do I do? I've been searching for an article that would help me with doing something like this but I've failed to find one. Any help is appreciated.
 
David Mace
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the solution to this would be to subclass the JScrollPane itself and then override the painting functions to implement the new buttons you are talking about...and of course to add their functionality. I would suppose this isn't a trivial task, but it's doable nonetheless.

Examine the source for JScrollPane and you'll get a feel for what needs to be done.

David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic