public void save() { for (String key : fields.keySet()) { JComponent comp = fields.get(key); if (comp instanceof JTextField) { JTextField c = (JTextField) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } else if (comp instanceof JTextArea) { JTextArea c = (JTextArea) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } } sketch.saveConfig(); }
public static void showResult(JTextArea txt, String result) { try { if (txt.getText().length() == 0) { txt.setText(result); txt.setSelectionStart(txt.getText().length()); txt.setSelectionEnd(txt.getText().length() - 1); } else { if (txt.getText().length() > MAX_LOG_SIZE) txt.getDocument().remove(0, txt.getText().length() - MAX_LOG_SIZE); txt.setSelectionStart(txt.getText().length()); txt.getDocument().insertString(txt.getText().length(), result, null); txt.setSelectionEnd(txt.getText().length()); } } catch (Exception e) { e.printStackTrace(); } }