Ejemplo n.º 1
0
 public void commitChanges() {
   res.put(PGameInformation.BACKGROUND_COLOR, editor.getBackground());
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   try {
     StyledDocument doc = (StyledDocument) editor.getDocument();
     rtf.write(baos, doc, doc.getStartPosition().getOffset(), doc.getLength());
     res.put(PGameInformation.TEXT, baos.toString("UTF-8")); // $NON-NLS-1$
   } catch (IOException e) { // Nevermind
     e.printStackTrace();
   } catch (BadLocationException e) { // Should never happen, but we have to catch this anyways
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 public void saveToFile() {
   fc.setDialogTitle(Messages.getString("GameInformationFrame.SAVE_TITLE")); // $NON-NLS-1$
   if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) return;
   String name = fc.getSelectedFile().getPath();
   if (CustomFileFilter.getExtension(name) == null) name += ".rtf"; // $NON-NLS-1$
   try {
     FileOutputStream out = new FileOutputStream(new File(name));
     StyledDocument doc = (StyledDocument) editor.getDocument();
     rtf.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength());
     out.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }