Reputation: 379
I am very new with gui and java so I am just trying out some things. I have this small code similar to Hello World, and even though there are no errors, when i run it all I get in the console is: mxGraph version "2.1.1.0" Any ideas what I did wrong? Thanks in advance
import javax.swing.JFrame;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
public class Design extends JFrame {
public Design() {
super("Test");
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 320);
f.setVisible(true);
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{
Object v1 = graph.insertVertex(parent, null, "hi", 20, 20, 80,
30);
Object v2 = graph.insertVertex(parent, null, "bye", 240, 150,
80, 30);
graph.insertEdge(parent, null, "Edge", v1, v2);
}
finally
{
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
add(graphComponent);
}
}
Upvotes: 0
Views: 147
Reputation: 159874
You're probably seeing the output from the classloader. Add a main
method to display the JFrame
itself
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Design design = new Design();
design.pack();
design.setVisible(true);
}
});
}
You should see
Upvotes: 2