[jgrapht-users] refreshing the view
Brought to you by:
barak_naveh,
perfecthash
From: Michał U. <mic...@op...> - 2017-05-28 19:07:31
|
ello I've created graph using JGraphT library g = new ListenableUndirectedWeightedGraph <String, MyEdge>(MyEdge.class); graphAdapter = new JGraphXAdapter<String, MyEdge>(g); layout = new mxOrganicLayout(graphAdapter); layout.execute(graphAdapter.getDefaultParent()); mxGraphComponent component = new mxGraphComponent(graphAdapter); component.setPreferredSize(new Dimension(dim.width - 50, dim.height - 200)); add(component); and I want to add dynamically a new vertex after pushing the button @Override public void actionPerformed(ActionEvent e) { String a="1"; String b="2"; g.addVertex(a); g.addVertex(b); g.addEdge(a,b); } public static class MyEdge extends DefaultWeightedEdge { //weight @Override public String toString() { return String.valueOf(getWeight()); } } how can I refresh the view? |