tags:

views:

202

answers:

2

The program I am writing has a Swing GUI and several of the components have Tooltips. These are all on JButton, JCheckBox and JRadioButton components, they are set using the setToolTipText method and all work perfectly. I have just tried to add one to a custom component that extends JPanel using the same method and no tool tip appears. The JPanel contains 2 JLabel components and a JSlider. I tried to override the setToolTipText method and then use it to call setToolTipText on the slider. This didn't work either.

public void setToolTipText(String text) {
    super.setToolTipText(text);
    slider.setToolTipText(text);
}

Am I doing something wrong? or can't you have a tooltip on a JSlider or JPanel. I would have thought that it should work on anything that extends JComponent.

The control is disabled when the program starts although even after it is enabled there is still no tool tip if that is relevant. It doesn't really need to show it until the control is enabled anyway.

Thanks.

A: 

Try making the following call:

ToolTipManager.sharedInstance().registerComponent(customComponent);
Nick Holt
That didn't work. Tried it with the slider as well but still nothing.
Android
+1  A: 

try settings the tooltip to the JLabels as well. they may be obstructing the JPanel.

Omry
Still nothing :(
Android
can you create a minimal java program that reproduces the problem and post it here?
Omry
I've just made one and it is working in that, will have to see what I am doing differently.
Android
that's a part of the reason I asked for it :)
Omry