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?.
Asked
Active
Viewed 381 times
0
-
if you have access to the graph you should just be able to call `graph.insertVertex()` with some params. you can search for an example in the [documentation] (https://jgraph.github.io/mxgraph/docs/manual_javavis.html) – iestync May 04 '16 at 14:26
1 Answers
1
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

iestync
- 121
- 6