示例#1
0
  // Method to saveFile().
  private void saveFile() {
    // If a file name is returned.
    if (fileName != null) {
      // Try block to throw a custom exception.
      try {
        // Save file.
        FileIO.saveFile(this, fileName, sender.getText());

      } // End of try to get message.
      catch (BufferEmptyException e) // Catch InvalidFileReference.
      {
        // Capture the stack trace into a String.
        setExceptionString(e.fillInStackTrace());

        // Pass message to the JOptionPane manager.
        setExceptionPane(
            "There is nothing in the sender panel to write.\n\n"
                + "Do you want to see the stack trace?");
      } // End of catch on BufferEmptyException.
    } // End of if a fileName is selected.
  } // End of saveFile() method.