0

How can I create a tooltip when clicking on vertex in Jgraph?

I tried the following code, but the tooltip is not showing, although the MousePressed event is invoked.

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);
                 }
            }
    }
  });
Mina Nabi
  • 3
  • 3
  • "but it didn't work" is broad. Be more specific please. – davidxxx Mar 19 '18 at 20:23
  • It does not show any tooltip. I have a Jframe and Jpanel on it and visualizing Jgraph on the panel. I tried the above code in the same class that I am creating the Jgraph. However the tooltip is not showing. I am pretty sure that the mouselistener is working since I could println the label of the vertex. (I should mention that I am really new in Java) – Mina Nabi Mar 19 '18 at 20:24

0 Answers0