private void saveMenuItemActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveMenuItemActionPerformed this.jTextStatus.setText(""); if (this.pnGraph.listEdges.isEmpty() && this.pnGraph.listVertexs.isEmpty()) { this.jTextStatus.setText("Empty graph, not save"); return; } if (this.jSaveFileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { File file = this.jSaveFileChooser.getSelectedFile(); try { BufferedWriter output = new BufferedWriter(new FileWriter(file)); try { for (Vertex Vertex : this.pnGraph.listVertexs) { output.write( String.format( "Vertex:%d:%d:%d", Vertex.getData(), Vertex.getX_cor(), Vertex.getY_cor())); output.newLine(); } for (Edge edge : this.pnGraph.listEdges) { output.write( String.format( "Edge:%d:%d:%d", edge.getHead().getData(), edge.getTail().getData(), edge.getLength())); output.newLine(); } this.jTextStatus.setText("Save graph successfully"); } finally { output.close(); } } catch (IOException e) { } } } // GEN-LAST:event_saveMenuItemActionPerformed