1 package com.mxgraph.examples.swing;
2 
3 import javax.swing.JFrame;
4 
5 import com.mxgraph.swing.mxGraphComponent;
6 import com.mxgraph.view.mxGraph;
7 
8 public class HelloWorld extends JFrame
9 {
10 
11 	/**
12 	 *
13 	 */
14 	private static final long serialVersionUID = -2707712944901661771L;
15 
HelloWorld()16 	public HelloWorld()
17 	{
18 		super("Hello, World!");
19 
20 		mxGraph graph = new mxGraph();
21 		Object parent = graph.getDefaultParent();
22 
23 		graph.getModel().beginUpdate();
24 		try
25 		{
26 			Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
27 					30);
28 			Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
29 					80, 30);
30 			graph.insertEdge(parent, null, "Edge", v1, v2);
31 		}
32 		finally
33 		{
34 			graph.getModel().endUpdate();
35 		}
36 
37 		mxGraphComponent graphComponent = new mxGraphComponent(graph);
38 		getContentPane().add(graphComponent);
39 	}
40 
main(String[] args)41 	public static void main(String[] args)
42 	{
43 		HelloWorld frame = new HelloWorld();
44 		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
45 		frame.setSize(400, 320);
46 		frame.setVisible(true);
47 	}
48 
49 }
50