Uses 1068K of libraries. Click here for Pure Java version (1504L/10K/37K).
!752 !1003435 // RSyntaxTextArea import org.fife.ui.rtextarea.*; import org.fife.ui.rsyntaxtextarea.*; static S snippetID = "#636"; static RSyntaxTextArea textArea; static JLabel status; static JButton btnSave; p { if (args.length != 0) snippetID = args[0]; snippetID = formatSnippetID(snippetID); JFrame frame = new JFrame(snippetID + " - " + getSnippetTitle(snippetID) + " [Edit]"); JPanel panel = new JPanel(new BorderLayout()); textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setCodeFoldingEnabled(true); textArea.setTabSize(2); textArea.setTabsEmulated(true); // Spaces are MUCH better RTextScrollPane sp = new RTextScrollPane(textArea); panel.add(BorderLayout.CENTER, sp); 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 #1000894
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003437 |
Snippet name: | Swing: Edit JavaX snippet |
Eternal ID of this version: | #1003437/1 |
Text MD5: | f5c05b42616f11bee461748d82f344f1 |
Transpilation MD5: | 9a6fc6930ac6152462770fa0f9b365ca |
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:52:40 |
Source code size: | 2458 bytes / 82 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 633 / 669 |
Referenced in: | [show references] |