public void setComponents(GameInformation info) { setEditorBackground((Color) res.get(PGameInformation.BACKGROUND_COLOR)); editor.setText(null); try { rtf.read( new ByteArrayInputStream( ((String) res.get(PGameInformation.TEXT)).getBytes("UTF-8")), // $NON-NLS-1$ editor.getDocument(), 0); } catch (IOException e) { // Nevermind } catch (BadLocationException e) { // Should never happen, but we have to catch this anyways } }
public void loadFromFile() { fc.setDialogTitle(Messages.getString("GameInformationFrame.LOAD_TITLE")); // $NON-NLS-1$ while (true) { if (fc.showOpenDialog(LGM.frame) != JFileChooser.APPROVE_OPTION) return; if (fc.getSelectedFile().exists()) break; JOptionPane.showMessageDialog( null, fc.getSelectedFile().getName() + Messages.getString("SoundFrame.FILE_MISSING"), // $NON-NLS-1$ Messages.getString("GameInformationFrame.LOAD_TITLE"), // $NON-NLS-1$ JOptionPane.WARNING_MESSAGE); } try { FileInputStream i = new FileInputStream(fc.getSelectedFile()); editor.setText(""); // $NON-NLS-1$ rtf.read(i, editor.getDocument(), 0); i.close(); } catch (Exception e) { e.printStackTrace(); } }