!752 static S snippetID = "#636"; static JTextArea textArea; static JLabel status; static JButton btnSave; p { if (args.length != 0) snippetID = args[0]; snippetID = formatSnippetID(snippetID); JFrame frame = new JFrame(snippetID + " - Edit"); JPanel panel = new JPanel(new BorderLayout()); textArea = newTypeWriterTextArea(); panel.add(BorderLayout.CENTER, new JScrollPane(textArea)); status = new JLabel("Loading..."); btnSave = new JButton("Save " + snippetID); btnSave.setEnabled(false); textArea.setEditable(false); // still loading btnSave.addActionListener(actionListener { saveSnippet(); }); JPanel bottom = new JPanel(new BorderLayout); bottom.add(BorderLayout.CENTER, status); bottom.add(BorderLayout.EAST, btnSave); panel.add(BorderLayout.SOUTH, bottom); onUpdate(textArea, r { btnSave.setEnabled(true); }); thread { final S s = loadSnippet(snippetID); awt { status.setText("Loaded " + s.length() + " chars."); textArea.setText(s); //textArea.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); textArea.setCaretPosition(0); btnSave.setEnabled(false); textArea.setEditable(true); textArea.requestFocus(); } } frame.add(panel); frame.setBounds(100, 100, 500, 400); frame.setVisible(true); exitOnFrameClose(frame); } static void saveSnippet() { final S text = textArea.getText(); btnSave.setEnabled(false); status.setText("Saving..."); thread { final S url = "http://tinybrain.de:8080/tb-int/update_snippet_text.php"; S user = loadTextFile(new File(userHome(), ".tinybrain/username").getPath(), null); S pass = loadTextFile(new File(userHome(), ".tinybrain/userpass").getPath(), null); S query = "id=" + parseSnippetID(snippetID) + "&text=" + urlencode(text) + "&_user=" + urlencode(user) + "&_pass=" + urlencode(pass); final S page = doPost(query, url); awt { status.setText("Saved snippet: " + page); } } }