Hi all,
this is beyond me (be forgiving, it's late). I'm subclassing a WindowsSliderUI, because I want it to draw a bigger thumb (is that the right word?)(that's working) and also display the value of the slider just above it (like, for example, gtk look and feel does)(that's broken). I'm overriding the paint() method, and at the moment it looks like this: (it's long, my changes are near the bottom):
Rectangle knobBounds = thumbRect;
int w = knobBounds.width;
int h = knobBounds.height;
g.translate(knobBounds.x, knobBounds.y);
if ( slider.isEnabled() ) {
g.setColor(slider.getBackground());
}
else {
g.setColor(slider.getBackground().darker());
}
Boolean paintThumbArrowShape =
(Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
paintThumbArrowShape == Boolean.FALSE) {
// "plain" version
g.fillRect(0, 0, w, h);
//THE ONES THAT MATTER
g.setColor(Color.BLACK);
String val = slider.getValue()+"";
g.drawString(val, 0, 0);
g.setColor(Color.RED);
g.drawLine(0, 0, 30, 8);
//END
g.setColor(Color.black);
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, 0, w-1, h-1);
g.setColor(getHighlightColor());
g.drawLine(0, 0, 0, h-2);
g.drawLine(1, 0, w-2, 0);
g.setColor(getShadowColor());
g.drawLine(1, h-2, w-2, h-2);
g.drawLine(w-2, 1, w-2, h-3);
}
all i want is to get the value displayed just above the thumb. however, what happens now is the string gets displayed initially, but when i drag the slider, it stays in the same place (not changing value) until i release the mouse button, at which point it is redrawn at the right place with the right value. and just to make my head go even funnier, the drawLine() method works fine - the line is always on the thumb when i drag it. now, this is probably trivial mistake (i'm really no good, and tired), but please help me find it. mind you, if you see a better approach to the whole problem, let me know as well. as i said, i'm really no good with this, and i tend to make things more complicated than they are.
thanks a lot