tags:

views:

51

answers:

3

I have a JSlider in my gui that goes from 0 to 100, for some reason, there is a text above the slider position that reads the current value of the slider and it follows my slider around. I.e., if I move my slider halfway, "50" appears above where my slider currently is. However, I can't figure out what that text field is called, all I know is its part of the slider.

I want to either remove it or be able to change it to something else, how would I do that?

A: 

As I see there is a setLabelTable method in JSlider with a Dictionary parameter. I have not used it but I guess that if you set it to an empty dictionary (or empty labels for every possible value) then no labels will appear.

A better solution is the usage of setPaintLabels with a false value.

rics
nope, already tried it, the labelTable is used to mark the labels for the slider (the labels that go below a slider), it doesn't affect the value above the slider at all.
yx
I think those have to do with the tick marks.
Mark Peters
followup comment, setPaintLabels already defaults to false, and it affects the labels that you set with setLableTable, which is NOT what the slider value is. So it also doesn't work. Like Mark said, those are for the tick mark labels, not the slider value I'm talking about.
yx
Sorry, then, it is getting more interesting, upvote to the question.
rics
A: 

Do you mean a tooltip? Is it a little box that appears over the slider control and follows your mouse around if you grab the slider? If this is the case, you can disable it simply by calling setToolTipText( null ), or override the text with setToolTipText( "My Text" ).

wolfcastle
+1  A: 

This bothered me on a project once, and I found the following workaround. Call this once before instantiating your JSlider -- I put it in a static block in my JPanel subclass:

UIManager.put("Slider.paintvalue", false);

That'll take care of it.

Etaoin