0

我正在使用 Java,我需要保存我的 JGraph。当我打开文件时,我什么也没找到,文件是Textdocument.

String filename="C:\\Users\\asmaa\\Desktop\\PFE\\asma" ;
mxCodecRegistry.register(new mxModelCodec( new mxGraphModel())); 
     try {

  mxGraph graph = graphComponent.getGraph();

  // taken from EditorActions class
  mxCodec codec = new mxCodec();
  String xml = mxXmlUtils.getXml(codec.encode(graph.getModel()));
  mxUtils.writeFile(xml,filename );

  JOptionPane.showMessageDialog( graphComponent, "File saved to: " + filename);

} catch( Exception ex) {
  throw new RuntimeException( ex);
}

谁能告诉我我的代码有什么问题?

4

0 回答 0