如何在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);
}
}
}
});