Leks
Leks

Reputation: 77

JGraphx Graph Editor with Initial Vertex

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?.

Upvotes: 0

Views: 396

Answers (1)

iestync
iestync

Reputation: 121

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

Upvotes: 1

Related Questions