在jgraph中,是否有类似于.getText()的函数;对于一个顶点? 我需要将文本附加到标签中。
谢谢。
最佳答案
如果您右键单击顶点,此示例将打印顶点的标签。
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());
}
}
}
});
关于label - 如何通过单击顶点(Jgraph)来获取顶点的字符串(标签)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24362273/