# Has anyone played with JGraphx?

**URL:** <https://forum.inductiveautomation.com/t/has-anyone-played-with-jgraphx/15674>\
**Category:** General Discussion\
**Created:** [October 16, 2017, 12:35am UTC](https://forum.inductiveautomation.com/t/has-anyone-played-with-jgraphx/15674 "2017-10-16T00:35:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [October 16, 2017, 12:35am UTC](https://forum.inductiveautomation.com/t/has-anyone-played-with-jgraphx/15674/1 "2017-10-16T00:35:26Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a25259feceacc38c04095001cf89ce93439db6fb.png)

```auto
gLib = 'C:\\Program Files\\Inductive Automation\\Ignition\\lib\\core\\designer\\jgraphx.jar'

import sys
sys.path.append(gLib)

from javax.swing import JFrame
from com.mxgraph.swing import mxGraphComponent
from com.mxgraph.view import mxGraph

class HelloWorld(JFrame):
	def example(self):
		graph = mxGraph()
		parent = graph.getDefaultParent()
		graph.getModel().beginUpdate()
		v1 = graph.insertVertex(parent, None, "Hello", 20, 20, 80, 30)
		v2 = graph.insertVertex(parent, None, "World!", 240, 150, 80, 30)
		graph.insertEdge(parent, None, "Edge", v1, v2)
		graph.getModel().endUpdate()
		graphComponent = mxGraphComponent(graph)
		self.getContentPane().add(graphComponent)
	
frame = HelloWorld()
frame.example()
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
frame.setSize(400, 320)
frame.setVisible(True)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 16, 2017, 1:20am UTC](https://forum.inductiveautomation.com/t/has-anyone-played-with-jgraphx/15674/2 "2017-10-16T01:20:27Z")

</div>

Intriguing. Not familiar with this package, but could you use the mxGraph() object in a script playground instead of wrapping it in a component?

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [October 31, 2017, 1:07pm UTC](https://forum.inductiveautomation.com/t/has-anyone-played-with-jgraphx/15674/3 "2017-10-31T13:07:09Z")

</div>

Here is the graph in a container.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5b43c1e0c2b030bad0eaf1ac34a78db7180ef2e6.PNG)

```auto
gLib = 'C:\\temp\\jgraphx.jar'

import sys
sys.path.append(gLib)

from javax.swing import JFrame
from com.mxgraph.swing import mxGraphComponent
from com.mxgraph.view import mxGraph

#pane = event.source.parent.parent.parent.getContentPane()
pane = event.source.parent.getComponent('contGraph')
graph = mxGraph()
parent = graph.getDefaultParent()
graph.getModel().beginUpdate()
v1 = graph.insertVertex(parent, None, "Hello", 20, 20, 80, 30)
v2 = graph.insertVertex(parent, None, "World!", 240, 150, 80, 30)
graph.insertEdge(parent, None, "Edge", v1, v2)
graph.getModel().endUpdate()
graphComponent = mxGraphComponent(graph)
pane.addComponent(graphComponent)
system.gui.resizeComponent(graphComponent,pane.width,pane.height)

```
