javaswingselectionedgesjgraphx

How do I disable edge selection only in JGraphX?


I'm trying to disable edge selection only in JGraphX. If I call

mxgraph.setCellsSelectable(false);

This disables selection on all cell, not just edges. Is there something like a setEdgesSelectable()?


Solution

  • Override:

    public boolean isCellsSelectable()
    

    in an mxGraph subclass and use that sub-class. By default that returns mxgraph.cellsSelectable. You want something like (not tested at all):

    public boolean isCellsSelectable()
    {
        if (model.isEdge())
        {
            return false;
        }
    
        return cellsSelectable;
    }