public void actionPerformed(ActionEvent e) {
JGraph jgraph = (JGraph) e.getSource();
GraphPane graphPane = jgraph.getGraphPane();
GraphController controller = graphPane.getGraphController();
GraphModel graphModel = controller.getGraphModel();
SelectionModel model = controller.getSelectionModel();
Object[] selection = model.getSelectionAsArray();
Object[] userObjects = new Object[selection.length];
// First remove the selection.
for (int i = 0; i < selection.length; i++) {
userObjects[i] = ((Figure) selection[i]).getUserObject();
model.removeSelection(selection[i]);
}
// Remove all the edges first, since if we remove the nodes first,
// then removing the nodes might remove some of the edges.
for (int i = 0; i < userObjects.length; i++) {