简体   繁体   English

在JGraphX中将ActionListener添加到mxcell

[英]Adding ActionListener to the mxcell in JGraphX

I want to add "Action Listener" to the mxcell(vertex) in JGraphX. 我想将“动作监听器”添加到JGraphX中的mxcell(vertex)中。 If I Double Clicked on the mxcell vertex it should do some action. 如果我双击mxcell顶点,则应执行某些操作。 Is there any way to add action listener to the mxcell vertex in jGraphX ?. 有什么方法可以将动作侦听器添加到jGraphX中的mxcell顶点?

On mouse click event on the graph component get the cell and add action event to the cell. 在图形组件上的鼠标单击事件上,获取单元格并将动作事件添加到该单元格。

public void mouseClicked(MouseEvent e)
{
Object cell=graphComponent.getCellAt(e.getX(),e.getY());
if(cell!=null&& cell instanceof mxcell)
{
if(((mxcell)cell.getValue().toString().equals("cell-name"))
{
// your function
}
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM