单击Jgraph中的顶点时如何创建工具提示?
我尝试了以下代码,但没有显示工具提示,尽管调用了 MousePressed 事件。
ToolTipManager.sharedInstance().registerComponent(jgraph);
jgraph.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
int x = e.getX(), y = e.getY();
Object cell= jgraph.getFirstCellForLocation(x, y);
if (cell != null) {
String lab = jgraph.convertValueToString(cell);
jgraph.setToolTipText(lab);
System.out.println(lab);
}
}
}
});