!7 // TODO: capture all of System.out/System.err sclass SystemPrintLog extends DynModule { transient StringBuffer log; transient JTextArea ta; int linesToShow = 100; start { if (dm_getBounds() == null) { print("Setting frame rect"); dm_setBounds(this, 0, max(0, getHeight(dm_desktopPane())-200), 400, 200); } log = getCreator('print_log); doEvery(1000, r updateMe); } visualize { ret componentPopupMenuItems(jSection("SYSTEM LOG", ta = moveCaretToEnd(typeWriterTextArea(str(log)))), "Clear", r { clearStringBuffer(log) }, "Copy to new window", r { showText("System Log", log) }); } void unvisualize() { ta = null; } void update { if (ta != null) setText(ta, extractLastNLinesOfString(linesToShow, str(log)); } }