static class LogView extends JScrollPane { JTextPane textPane; *() { textPane = new JTextPane(); textPane.setEditable(false); setViewportView(textPane); } // thread safe public void logText(final String text) { awt { System.out.println("printing"); Document document = textPane.getDocument(); System.out.println("inserting"); document.insertString(document.getLength(), text, null); System.out.println("done printing"); // todo: scroll? } } // log some pure text and add a line feed // thread safe public void println(String line) { logText(line + "\n"); } // thread safe public void clear() { awt { textPane.setText(""); } } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000815 |
Snippet name: | Buggy LogView (Swing insertString bug) |
Eternal ID of this version: | #1000815/1 |
Text MD5: | b8780ac726e165fed9bafff008b65258 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-28 20:23:24 |
Source code size: | 756 bytes / 33 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 697 / 1087 |
Referenced in: | [show references] |