Exemplo n.º 1
0
  @Override
  public synchronized void run() {
    try {
      for (int i = 0; i < NUM_PIPES; i++) {
        while (Thread.currentThread() == reader[i]) {
          try {
            this.wait(100);
          } catch (InterruptedException ie) {
          }
          if (pin[i].available() != 0) {
            String input = this.readLine(pin[i]);
            appendMsg(htmlize(input));
            if (textArea.getDocument().getLength() > 0) {
              textArea.setCaretPosition(textArea.getDocument().getLength() - 1);
            }
          }
          if (quit) {
            return;
          }
        }
      }

    } catch (Exception e) {
      Debug.error(me + "Console reports an internal error:\n%s", e.getMessage());
    }
  }
Exemplo n.º 2
0
 // For compatibility with writers when talking to the JVM.
 public void write(char[] buffer, int offset, int length) {
   String text = new String(buffer, offset, length);
   SwingUtilities.invokeLater(
       () -> {
         try {
           pane.getDocument().insertString(pane.getDocument().getLength(), text, properties);
         } catch (Exception e) {
         }
       });
 }
Exemplo n.º 3
0
 private void appendMsg(String msg) {
   HTMLDocument doc = (HTMLDocument) textArea.getDocument();
   HTMLEditorKit kit = (HTMLEditorKit) textArea.getEditorKit();
   try {
     kit.insertHTML(doc, doc.getLength(), msg, 0, 0, null);
   } catch (Exception e) {
     Debug.error(me + "Problem appending text to message area!\n%s", e.getMessage());
   }
 }
Exemplo n.º 4
0
 // Appends text to the end of the log, using the provided settings. Doesn't add a new line.
 private static void print(String message, SimpleAttributeSet settings) {
   try {
     outputText
         .getDocument()
         .insertString(outputText.getDocument().getLength(), message, settings);
   } catch (BadLocationException e) {
     try {
       outputText
           .getDocument()
           .insertString(
               outputText.getDocument().getLength(),
               "Couldn't insert message \"" + message + "\".",
               progErr);
     } catch (BadLocationException b) {
       // If you ever reach this error, something is seriously wrong, so just please swallow it and
       // ignore it.
     }
   }
 }