I have my output window as shown here
My complete code is:
http://codes-at-igit.weebly.com/uploads/1/2/2/7/12272842/travellingsalesmanproblem.java
The circles are different G.P.S locations. I want to show the location i.e. , the longitude and latitude when mouse hovers on a node. I tried set tool tip text but it doesn't give privilege to specify the locations at which the text should occur. I have coded it in swing Java . I am working in Netbeans 7.1.2. So how can I do this?
How do I set tool tip text at a particular position?
set tooltip text at a particular location
10.8k Views Asked by user1503567 At
2
There are 2 best solutions below
0
On
Try over-riding getToolTipLocation(), for example:
JButton buttonAbove = new JButton("Above") {
public Point getToolTipLocation(MouseEvent e) {
return new Point(20, -30);
}
};
from here: http://www.java2s.com/Code/Java/Swing-JFC/ToolTipLocationExample.htm
You can simply override
public String getToolTipText(MouseEvent event)of the underlying JComponent. Then based on the location of the event you can return null or the tooltip related to the node.Here is a small snippet demonstrating this: