public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER) { document.enter(); e.consume(); } }
/** * simple TextArea that always scrolls to the bottom. Also creates an out and err PrintWriter so * that you can redirect stdout/stderr to these streams, using the System.setOut/setErr methods. */ public ReplPane(ReplDocument document) { super(document); this.document = document; document.pane = this; document.paneCount++; addKeyListener(this); addFocusListener(document); setCaretPosition(document.outputMark); }
/** * This method is called by the toolkit when the component is removed. Used as a hook to decrement * ReplDocument's reference count, and maybe close the document. */ @Override public void removeNotify() { super.removeNotify(); if (--document.paneCount == 0) document.close(); }