How to Customize an AWT Scrollbar?

R

RJGraham

Hello,

I'd like to customize a scrollbar to add a simple inidcator showing an
'actual' value that tracks along side the scrollbar thumbar.
I use the scrollbar to set a value, and the indicator shows the actual
'measured' value in or beside the thumb bar track.

Is there any way to determine the client coordinates of the thumb bar track
so that I can draw my indicator inside or next to it?

I don't see how from the docs.

Also, my application must be JDK 1.1 compliant.so I'm limited to using AWT.

Thanks for any suggestions.

-Randy
 
S

Steven Coco

RJGraham said:
Is there any way to determine the client coordinates of the thumb bar track
so that I can draw my indicator inside or next to it?

In truth, what you are looking for must be done in native code. However:

a) Somewhat realistically; use the scrollbar's size and the current
value and min/max values to determine where the thumb _should_ be and
see if that doesn't work.

b) --When you go *crazy*, you can try another thing--but good luck:
Check the 1.1 AWT library for some way to capture a graphics context of
the pixels on the screen which will include the thumb and do some _real_
TRICKERY to find and track the thumb using the pixels!

--

..Steven Coco.
.........................................................................
When you're not sure:
"Confess your heart" says the Lord, "and you'll be freed."
 
R

RJGraham

Thanks for your suggestions.

a) won't work for me since I really need to know the size of the thumbtrack
'slide' area to accurately place my indicator.

b) sounds really nasty ;)

Maybe I just need to bight my fist and write my own scrollbar.

-Randy
 
S

Steven Coco

RJGraham said:
Maybe I just need to bight my fist and write my own scrollbar.

You know what: my reply was completely AWT-centric. If you use
Swing--n.b. from my post you should be able to tell I am not familiar
with the library--(since the components are lightweight) you should be
able to hack at a JScrollBar and find the parts you need in Java code.

--

..Steven Coco.
.........................................................................
When you're not sure:
"Confess your heart" says the Lord, "and you'll be freed."
 
R

RJGraham

Hey, now that's a good idea.

Thanks !

-Randy

Steven Coco said:
You know what: my reply was completely AWT-centric. If you use
Swing--n.b. from my post you should be able to tell I am not familiar
with the library--(since the components are lightweight) you should be
able to hack at a JScrollBar and find the parts you need in Java code.

--

.Steven Coco.
........................................................................
When you're not sure:
"Confess your heart" says the Lord, "and you'll be freed."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top