我对 gui 和 java 很陌生,所以我只是在尝试一些东西。我有这个类似于 Hello World 的小代码,即使没有错误,当我运行它时,我在控制台中得到的只是:mxGraph 版本“2.1.1.0”任何想法我做错了什么?提前致谢
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);
}
}