Libraryless. Click here for Pure Java version (1502L/10K/36K).
!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); } } }
Began life as a copy of #1000881
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000894 |
Snippet name: | Swing: Edit text snippet |
Eternal ID of this version: | #1000894/1 |
Text MD5: | dfa14818ccc77c8ddd79be0fbb760a93 |
Transpilation MD5: | 534b01e473d81bc558a6c4f95ac3f888 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-03 15:48:20 |
Source code size: | 2073 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 775 / 820 |
Referenced in: | [show references] |