Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1000820 // LogView based on JTextArea

JavaX fragment (include)

static class LogView extends JScrollPane {
  JTextArea textArea;

  *() {
    textArea = new JTextArea;
    textArea.setEditable(false);
    setViewportView(textArea);
  }

  // thread safe
  public void logText(final String text) {
    awt {
      textArea.append(text);

      // todo: scroll?
    }
  }
  
  // thread safe
  void print(String text) {
    logText(text);
  }

  // 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 { textArea.setText(""); }
  }
}

Author comment

Began life as a copy of #1000815

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: #1000820
Snippet name: LogView based on JTextArea
Eternal ID of this version: #1000820/1
Text MD5: 54fb7e868e2a4b3188e6ffb08fb9734e
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-28 20:37:01
Source code size: 622 bytes / 34 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 647 / 1139
Referenced in: #1000821 - LogView test 2
#1000822 - TextArea LogView test that ALSO hangs...
#1000824 - Redirecting stdout+stderr to LogView test
#3000382 - Answer for ferdie (>> t = 1, f = 0)