I have made a small example to illustrate my problem.
I have overwritten the createToolTip method for a custom JComponent (eventually it will depend on where abouts the mouse is in the component as to what text to bring up) At first I thought it wasn't being called, but i added the colour changing and it is.
The tooltip text doesn't change from "testTip" but the colours do change. I added the println and the output is:
null
something else
so the text is null, i'm setting it, but all that is ignored because the tooltip actually shows "testTip"
I also tried adding
public String getToolTipText()
{
return "woop";
}
but this causes there to be no tooltip at all!
Here's my example program, any help is appreciated:
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JToolTip;
public class Test extends JComponent
{
public Test()
{
setToolTipText("testTip");
}
public JToolTip createToolTip() {
JToolTip tip = super.createToolTip();
System.out.println(tip.getTipText());
tip.setBackground(Color.YELLOW);
tip.setForeground(Color.RED);
tip.setTipText("something else");
tip.setToolTipText("Something really else");
System.out.println(tip.getTipText());
return tip;
}
public static void main(String[] args)
{
Test t = new Test();
JFrame f = new JFrame("test");
f.add(t);
f.pack();
f.setVisible(true);
}
}