Leks
Leks

Reputation: 77

Adding ActionListener to the mxcell in JGraphX

I want to add "Action Listener" to the mxcell(vertex) in JGraphX. If I Double Clicked on the mxcell vertex it should do some action. Is there any way to add action listener to the mxcell vertex in jGraphX ?.

Upvotes: 0

Views: 787

Answers (1)

Leks
Leks

Reputation: 77

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
}
}
}

Upvotes: 1

Related Questions