• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drawing my own ScrollBar

 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic