Tooltips usage

I've got a JSlider and I need to print it's value in a tooltip that
appears at the cursor position every time mouse enters the
slider or changes its value (the tooltip should "chase" mouse
position).
I've been trying this:

// overridden, so that the tooltip follows the mouse position
public Point getToolTipLocation(MouseEvent event) {
return new Point(event.getX() + 15, event.getY());
}
}

BTW, what makes you want to use tooltips to display the current slider
value?
Why not doing it more conventional?, i.e. by using the JSlider-API to
draw ticks/labels permanently. For example:
this.setPaintLabels(true);
this.setMajorTickSpacing(20);
this.setMinorTickSpacing(5);
this.setPaintTicks(true);

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!