I'm Customizing jgraphx graph editor example program. In the graph editor program we can add the vertex to the graph by drag and drop icon from the palette. But i need to add a initial vertex to the graph that means, In the initial[New] graph editor frame the graph editor's graph should contain one vertex. How can I add a initial vertex to the graph without drag and drop from a palette?.
If you have the jgraphx project checked out, in the GraphEditor try using the insertVertex method in the constructor as follows:
public GraphEditor(String appTitle, mxGraphComponent component)
{
super(appTitle, component);
final mxGraph graph = graphComponent.getGraph();
graph.insertVertex(graph.getDefaultParent(), null, "Test", 100, 100, 200, 100);
...
}
This should give you a vertex to start from
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.