2

In jgraph, is there a function similiar to the .getText(); for a vertex? I need to get the text attached to them in the label.

Thanks.

mc110
  • 2,825
  • 5
  • 20
  • 21
Carlos
  • 49
  • 1
  • 1
  • 8

1 Answers1

2

This example prints you the label of the vertex if you right click on it.

graphComponent.getGraphControl().addMouseListener(new MouseAdapter() 
{
    @Override
    public void mousePressed(MouseEvent e) 
    {
        if (SwingUtilities.isRightMouseButton(e))
        {       
            mxCell cell =(mxCell) getGraphComponent().getCellAt(e.getX(), e.getY());

            if(cell != null)
            {
                System.out.println(cell.getValue().toString());
            }
        }
   }
});
Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63