I'm trying to make a graph with JGraphX in Java and add a mouseListener
on a specific type of vertex.
I've attempted to use graphComponent
but it does nothing...
This is my code:
mxGraphComponent graphComponent = new mxGraphComponent(graph);
graphComponent.getGraphControl().addMouseListener( new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
mxCell cell = (mxCell) graphComponent.getCellAt(e.getX(), e.getY());
System.out.println("TOTO");
if(cell != null && cell instanceof mxCell){
if(cell.getValue().toString().equals("AAM")){
System.out.println("My Cell selected");
}
}
}
});