コード例 #1
0
 /** Load a Drawing from a file */
 protected void loadDrawing(StorageFormat restoreFormat, String file) {
   try {
     Drawing restoredDrawing = restoreFormat.restore(file);
     if (restoredDrawing != null) {
       restoredDrawing.setTitle(file);
       newWindow(restoredDrawing);
     } else {
       showStatus("Unknown file type: could not open file '" + file + "'");
     }
   } catch (IOException e) {
     showStatus("Error: " + e);
   }
 }
コード例 #2
0
  protected void loadDrawing(String param) {
    if (param == fgUntitled) {
      fDrawing.release();
      initDrawing();
      return;
    }

    String filename = getParameter(param);
    if (filename != null) {
      readDrawing(filename);
    }
  }
コード例 #3
0
  private void readFromStorableInput(String filename) {
    try {
      URL url = new URL(getCodeBase(), filename);
      InputStream stream = url.openStream();
      StorableInput input = new StorableInput(stream);
      fDrawing.release();

      fDrawing = (Drawing) input.readStorable();
      view().setDrawing(fDrawing);
    } catch (IOException e) {
      initDrawing();
      showStatus("Error:" + e);
    }
  }
コード例 #4
0
 private void readFromObjectInput(String filename) {
   try {
     URL url = new URL(getCodeBase(), filename);
     InputStream stream = url.openStream();
     ObjectInput input = new ObjectInputStream(stream);
     fDrawing.release();
     fDrawing = (Drawing) input.readObject();
     view().setDrawing(fDrawing);
   } catch (IOException e) {
     initDrawing();
     showStatus("Error: " + e);
   } catch (ClassNotFoundException e) {
     initDrawing();
     showStatus("Class not found: " + e);
   }
 }