wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Drawing my own ScrollBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drawing my own ScrollBar" Watch "Drawing my own ScrollBar" New topic
Author

Drawing my own ScrollBar

Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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

Joined: May 26, 2004
Posts: 35
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


Dad always thought laughter was the best medicine, which I guess is why several of us died of tuberculosis. -Jack Handy
 
 
subject: Drawing my own ScrollBar
 
Similar Threads
GridBag help
Graphics Object & Graphics Context
How to i go about .....
Determining properties of the browser screen
Which Container should I use?