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.

4

1 回答 1

2

如果您右键单击它,此示例会为您打印顶点的标签。

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());
            }
        }
   }
});
于 2014-09-10T09:38:04.363 回答