I extended JGoView.java and overridden the method getTooltipLocation(MouseEvent) of JComponent. But I found that the call does not reach this method when the tooltip gets invoked.
Now I am trying to extend JGoViewCanvas.java to override getTooltipLocation(MouseEvent). But overriding JGoViewCanvas.java results in exception.
Can anyone tell me a way to override this method for a JGoView. I want to add some customizations to it.
Overrideing JGoView.getTooltipLocation(MouseEvent) is the right thing to do. This is in fact how tooltips are supported in all of JGo. Take a look at this override in the Demo1 sample application for an example.
Thanks forthe reply. Actually I had overridden JGoView.getTooltipLocation(MouseEvent), but I verified that the flow does not reach this overridden method when the tooltip gets invoked. I could override createTooltip() method though. I think the reason is that JGoViewCanvas.java has a createTooltip() method which delegates the flow to createToolTip() method of JGoView.
JGoViewCanvas does not have getTooltipLocation(MouseEvent) method in it. So that's why, like creaeTooltip() method, I cannot override getTooltipLocation(MouseEvent) in my JGoView.
JGoViewCanvas is a JComponent added "over" JGoView, so all method calls first reach JGoViewCanvas and that's why the flow never reaches the overridden getTooltipLocation(MouseEvent) of JGoView. This is what I feel. Hope my doubt is clear.
Actually my problem is that, by default, the tooltips that appear on JGoIconicNodes in my JGoPalette, are sometimes slightly away from the actual mouse location. This may be because of the size of the JGoIconicNode that I am using in JGoPalette.
In the tooltip I am having a clickable hyperlink, but because of this gap between mouse location and the tooltip, I am never able to reach the hyperlink. As soon as I reach the tooptip it disappears.
So that's why I wanted to override getTooltipLocation(MouseEvent) to customize the tooptip location.
But I am unable to extend JGoViewCanvas.java to override getToolTipLocation(MouseEvent), may be because JGoViewCanvas is an inner class inside JGoView. I am overriding JGoView and JGoViewCanvas as follows:
Please let me know if this is the right way to override JGoViewCanvas. Please let me know the correction if I am wrong. The above code is not working and throwing exception as I have shown in the code above.
And when I override getToolTipLocation(MouseEvent) of JGoView (in WECanvas), it does not have any effect. The code doesn't reach th method at runtime.
We will put the following definition of JGoViewCanvas.getToolTipText(MouseEvent) into the next release of JGo:
public Point getToolTipLocation(MouseEvent e) {return myView.getToolTipLocation(e);}
and we will put the following in JGoView:
public Point getToolTipLocation(MouseEvent e) {return null;}
This will allow you to specify the tooltip location by overriding JGoView.
In the meantime, you can make the same modification to JGoViewCanvas yourself, as the source code for JGoViewCanvas is included in JGoView.java in the JGo kit.