Package: groovy.console.ui

## [Groovy] Class Console

- groovy.console.ui.Console

- All Implemented Interfaces and Traits:
    CaretListener, HyperlinkListener, ComponentListener, FocusListener

      class Console
      extends Object
      implements CaretListener, HyperlinkListener, ComponentListener, FocusListener

  Groovy Swing console. Allows user to interactively enter and execute Groovy.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `class` | `Console.1` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static URL` | `ICON_PATH` |
    `static URL` | `NODE_ICON_PATH` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static String` | `DEFAULT_SCRIPT_NAME_START`
    `Closure` | `afterExecution`
    `boolean` | `autoClearOutput`
    `Action` | `autoClearOutputAction`
    `CompilerConfiguration` | `baseConfig`
    `Closure` | `beforeExecution`
    `Component` | `blank`
    `static boolean` | `captureStdErr`
    `static boolean` | `captureStdOut`
    `int` | `colNum`
    `Style` | `commandStyle`
    `CompilerConfiguration` | `config`
    `static Object` | `consoleControllers`
    `ConsolePreferences` | `consolePreferences`
    `Component` | `copyFromComponent`
    `File` | `currentClasspathDir`
    `File` | `currentClasspathJarDir`
    `File` | `currentFileChooserDir`
    `int` | `cursorPos`
    `boolean` | `detachedOutput`
    `Action` | `detachedOutputAction`
    `boolean` | `dirty`
    `RootPaneContainer` | `frame`
    `static Object` | `frameConsoleDelegates`
    `boolean` | `fullStackTraces`
    `Action` | `fullStackTracesAction`
    `static Object` | `groovyFileFilter`
    `Action` | `hideOutputWindowAction1`
    `Action` | `hideOutputWindowAction2`
    `Action` | `hideOutputWindowAction3`
    `Action` | `hideOutputWindowAction4`
    `List` | `history`
    `int` | `historyIndex`
    `Style` | `hyperlinkStyle`
    `JTextPane` | `inputArea`
    `int` | `inputAreaContentHash`
    `ConsoleTextEditor` | `inputEditor`
    `Action` | `interruptAction`
    `boolean` | `loopMode`
    `Action` | `loopModeAction`
    `int` | `maxHistory`
    `int` | `maxOutputChars`
    `Action` | `nextHistoryAction`
    `boolean` | `orientationVertical`
    `Action` | `orientationVerticalAction`
    `int` | `origDividerSize`
    `JTextPane` | `outputArea`
    `PrintWriter` | `outputPrintWriter`
    `Style` | `outputStyle`
    `Component` | `outputWindow`
    `HistoryRecord` | `pendingRecord`
    `Action` | `prevHistoryAction`
    `Style` | `promptStyle`
    `Style` | `resultStyle`
    `Element` | `rootElement`
    `int` | `rowNum`
    `JLabel` | `rowNumAndColNum`
    `Thread` | `runThread`
    `Action` | `saveAction`
    `boolean` | `saveOnRun`
    `Action` | `saveOnRunAction`
    `Object` | `scriptFile`
    `int` | `scriptNameCounter`
    `boolean` | `scriptRunning`
    `Component` | `scrollArea`
    `Action` | `selectPreviousWordAction`
    `Action` | `selectWordAction`
    `GroovyShell` | `shell`
    `Action` | `showOutputWindowAction`
    `boolean` | `showScriptInOutput`
    `Action` | `showScriptInOutputAction`
    `boolean` | `showToolbar`
    `Action` | `showToolbarAction`
    `static boolean` | `smartHighlighter`
    `JSplitPane` | `splitPane`
    `boolean` | `stackOverFlowError`
    `Style` | `stacktraceStyle`
    `JLabel` | `statusLabel`
    `SwingBuilder` | `swing`
    `SystemOutputInterceptor` | `systemErrorInterceptor`
    `SystemOutputInterceptor` | `systemOutInterceptor`
    `int` | `textSelectionEnd`
    `int` | `textSelectionStart`
    `boolean` | `threadInterrupt`
    `Action` | `threadInterruptAction`
    `Component` | `toolbar`
    `boolean` | `useScriptClassLoaderForScriptExecution`
    `boolean` | `visualizeScriptResults`
    `Action` | `visualizeScriptResultsAction`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `Console(Binding binding)`
    `Console(ClassLoader parent, Binding binding, CompilerConfiguration baseConfig)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `addClasspathDir(EventObject evt)`
    `` | `void` | `addClasspathJar(EventObject evt)`
    `` | `void` | `addToHistory(Object record)`
    `` | `void` | `appendOutput(String text, AttributeSet style)`
    `` | `void` | `appendOutput(Window window, AttributeSet style)`
    `` | `void` | `appendOutput(Object object, AttributeSet style)`
    `` | `void` | `appendOutput(Component component, AttributeSet style)`
    `` | `void` | `appendOutput(Icon icon, AttributeSet style)`
    `` | `void` | `appendOutputLines(Object text, Object style)`
    `` | `void` | `appendOutputNl(Object text, Object style)`
    `` | `void` | `appendStacktrace(Object text)`
    `` | `Object` | `askToInterruptScript()`
    `` | `boolean` | `askToSaveFile()`
    `` | `void` | `autoClearOutput(EventObject evt)`
    `` | `void` | `beep()`
    `` | `void` | `bindResults()`
    `` | `static void` | `captureStdErr(EventObject evt)`
    `` | `static void` | `captureStdOut(EventObject evt)`
    `` | `void` | `caretUpdate(CaretEvent e)`
    `` | `void` | `clearContext(EventObject evt)`
    `` | `void` | `clearOutput(EventObject evt)`
    `` | `void` | `closeOutputPrintWriter()`
    `` | `void` | `comment(EventObject evt)`
    `` | `void` | `compileAsJava(EventObject evt)`
    `` | `Object` | `compileFinishNormal()`
    `` | `void` | `compileScript(EventObject evt, Console.SourceType st)`
    `` | `void` | `componentHidden(ComponentEvent e)`
    `` | `void` | `componentMoved(ComponentEvent e)`
    `` | `void` | `componentResized(ComponentEvent e)`
    `` | `void` | `componentShown(ComponentEvent e)`
    `` | `void` | `copy(EventObject evt)`
    `` | `void` | `createOutputPrintWriter(File outputFile)`
    `` | `void` | `cut(EventObject evt)`
    `` | `void` | `detachedOutput(EventObject evt)`
    `` | `void` | `doInterrupt(EventObject evt)`
    `` | `int` | `dot(CaretEvent e)`
    `` | `boolean` | `exit(EventObject evt)`
    `` | `void` | `exitDesktop(EventObject evt, Object quitResponse)`
    `` | `void` | `fileNewFile(EventObject evt)`
    `` | `void` | `fileNewWindow(EventObject evt)`
    `` | `void` | `fileOpen(EventObject evt)`
    `` | `boolean` | `fileSave(EventObject evt)`
    `` | `boolean` | `fileSaveAs(EventObject evt)`
    `` | `void` | `find(EventObject evt)`
    `` | `void` | `findNext(EventObject evt)`
    `` | `void` | `findPrevious(EventObject evt)`
    `` | `Object` | `finishException(Throwable t, boolean executing)`
    `` | `Object` | `finishNormal(Object result, Long elapsedTime)`
    `` | `void` | `focusGained(FocusEvent e)`
    `` | `void` | `focusLost(FocusEvent e)`
    `` | `void` | `fullStackTraces(EventObject evt)`
    `` | `int` | `getConsoleId()`
    `` | `Object` | `getLastResult()`
    `` | `void` | `hideAndClearOutputWindow(EventObject evt)`
    `` | `void` | `hideOutputWindow(EventObject evt)`
    `` | `void` | `historyNext(EventObject evt)`
    `` | `void` | `historyPrev(EventObject evt)`
    `` | `void` | `hyperlinkUpdate(HyperlinkEvent e)`
    `` | `void` | `insertString(Document doc, int offset, String text, AttributeSet attributeSet, boolean outputToFile)`
    `` | `void` | `inspectAst(EventObject evt)`
    `` | `void` | `inspectCst(EventObject evt)`
    `` | `void` | `inspectLast(EventObject evt)`
    `` | `void` | `inspectTokens(EventObject evt)`
    `` | `void` | `inspectVariables(EventObject evt)`
    `` | `void` | `installInterceptor()`
    `` | `void` | `invokeTextAction(Object evt, Object closure, Object area)`
    `` | `void` | `largerFont(EventObject evt)`
    `` | `void` | `listClasspath(EventObject evt)`
    `` | `int` | `loadMaxOutputChars()`
    `` | `void` | `loadScriptFile(File file)`
    `` | `void` | `loopMode(EventObject evt)`
    `` | `static void` | `main(Object args)`
    `` | `int` | `mark(CaretEvent e)`
    `` | `void` | `newScript(ClassLoader parent, Binding binding)`
    `` | `static boolean` | `notifySystemErr(int consoleId, String str)`
    `` | `static boolean` | `notifySystemOut(int consoleId, String str)`
    `` | `void` | `orientationVertical(EventObject evt)`
    `` | `void` | `paste(EventObject evt)`
    `` | `void` | `preferences(EventObject evt)`
    `` | `void` | `print(EventObject evt)`
    `` | `void` | `redo(EventObject evt)`
    `` | `void` | `replace(EventObject evt)`
    `` | `void` | `run()`
    `` | `void` | `run(JApplet applet)` Runs the console embedded in the given applet.
    `` | `void` | `run(Map defaults)`
    `` | `void` | `runJava(EventObject evt)`
    `` | `void` | `runScript(EventObject evt, Console.SourceType st)`
    `` | `void` | `runSelectedJava(EventObject evt)`
    `` | `void` | `runSelectedScript(EventObject evt, Console.SourceType st)`
    `` | `void` | `saveOnRun(EventObject evt)`
    `` | `void` | `selectAll(EventObject evt)`
    `` | `void` | `selectBlock(EventObject evt)`
    `` | `Object` | `selectFilename(Object name)`
    `` | `void` | `setDirty(boolean newDirty)`
    `` | `void` | `setOutputPreferences(boolean useOutputFile, File outputFile)`
    `` | `void` | `setRowNumAndColNum()`
    `` | `void` | `setVariable(String name, Object value)`
    `` | `void` | `showAbout(EventObject evt)`
    `` | `void` | `showCompilingMessage()`
    `` | `void` | `showExecutingMessage()`
    `` | `void` | `showMessage(String message)`
    `` | `void` | `showOutputWindow(EventObject evt)`
    `` | `void` | `showScriptInOutput(EventObject evt)`
    `` | `void` | `showToolbar(EventObject evt)`
    `` | `void` | `smallerFont(EventObject evt)`
    `` | `void` | `smartHighlighter(EventObject evt)`
    `` | `void` | `threadInterruption(EventObject evt)`
    `` | `void` | `undo(EventObject evt)`
    `` | `void` | `updateTitle()`
    `` | `void` | `visualizeScriptResults(EventObject evt)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static URL ICON_PATH

    - #### public static URL NODE_ICON_PATH

  - ### Property Detail

    - #### static final String DEFAULT_SCRIPT_NAME_START

    - #### Closure afterExecution

    - #### boolean autoClearOutput

    - #### Action autoClearOutputAction

    - #### CompilerConfiguration baseConfig

    - #### Closure beforeExecution

    - #### Component blank

    - #### static boolean captureStdErr

    - #### static boolean captureStdOut

    - #### int colNum

    - #### Style commandStyle

    - #### CompilerConfiguration config

    - #### static Object consoleControllers

    - #### ConsolePreferences consolePreferences

    - #### Component copyFromComponent

    - #### File currentClasspathDir

    - #### File currentClasspathJarDir

    - #### File currentFileChooserDir

    - #### int cursorPos

    - #### boolean detachedOutput

    - #### Action detachedOutputAction

    - #### boolean dirty

    - #### RootPaneContainer frame

    - #### static Object frameConsoleDelegates

    - #### boolean fullStackTraces

    - #### Action fullStackTracesAction

    - #### static Object groovyFileFilter

    - #### Action hideOutputWindowAction1

    - #### Action hideOutputWindowAction2

    - #### Action hideOutputWindowAction3

    - #### Action hideOutputWindowAction4

    - #### List history

    - #### int historyIndex

    - #### Style hyperlinkStyle

    - #### JTextPane inputArea

    - #### int inputAreaContentHash

    - #### ConsoleTextEditor inputEditor

    - #### Action interruptAction

    - #### boolean loopMode

    - #### Action loopModeAction

    - #### int maxHistory

    - #### int maxOutputChars

    - #### Action nextHistoryAction

    - #### boolean orientationVertical

    - #### Action orientationVerticalAction

    - #### int origDividerSize

    - #### JTextPane outputArea

    - #### PrintWriter outputPrintWriter

    - #### Style outputStyle

    - #### Component outputWindow

    - #### HistoryRecord pendingRecord

    - #### Action prevHistoryAction

    - #### Style promptStyle

    - #### Style resultStyle

    - #### Element rootElement

    - #### int rowNum

    - #### JLabel rowNumAndColNum

    - #### Thread runThread

    - #### Action saveAction

    - #### boolean saveOnRun

    - #### Action saveOnRunAction

    - #### Object scriptFile

    - #### int scriptNameCounter

    - #### boolean scriptRunning

    - #### Component scrollArea

    - #### Action selectPreviousWordAction

    - #### Action selectWordAction

    - #### GroovyShell shell

    - #### Action showOutputWindowAction

    - #### boolean showScriptInOutput

    - #### Action showScriptInOutputAction

    - #### boolean showToolbar

    - #### Action showToolbarAction

    - #### static boolean smartHighlighter

    - #### JSplitPane splitPane

    - #### boolean stackOverFlowError

    - #### Style stacktraceStyle

    - #### JLabel statusLabel

    - #### SwingBuilder swing

    - #### SystemOutputInterceptor systemErrorInterceptor

    - #### SystemOutputInterceptor systemOutInterceptor

    - #### int textSelectionEnd

    - #### int textSelectionStart

    - #### boolean threadInterrupt

    - #### Action threadInterruptAction

    - #### Component toolbar

    - #### boolean useScriptClassLoaderForScriptExecution

    - #### boolean visualizeScriptResults

    - #### Action visualizeScriptResultsAction

  - ### Constructor Detail

    - #### Console(Binding binding)

    - #### Console(ClassLoader parent, Binding binding, CompilerConfiguration baseConfig)

  - ### Method Detail

    - #### void addClasspathDir(EventObject evt)

    - #### void addClasspathJar(EventObject evt)

    - #### void addToHistory(Object record)

    - #### void appendOutput(String text, AttributeSet style)

    - #### void appendOutput(Window window, AttributeSet style)

    - #### void appendOutput(Object object, AttributeSet style)

    - #### void appendOutput(Component component, AttributeSet style)

    - #### void appendOutput(Icon icon, AttributeSet style)

    - #### void appendOutputLines(Object text, Object style)

    - #### void appendOutputNl(Object text, Object style)

    - #### void appendStacktrace(Object text)

    - #### Object askToInterruptScript()

    - #### boolean askToSaveFile()

    - #### void autoClearOutput(EventObject evt)

    - #### void beep()

    - #### void bindResults()

    - #### static void captureStdErr(EventObject evt)

    - #### static void captureStdOut(EventObject evt)

    - #### void caretUpdate(CaretEvent e)

    - #### void clearContext(EventObject evt)

    - #### void clearOutput(EventObject evt)

    - #### void closeOutputPrintWriter()

    - #### void comment(EventObject evt)

    - #### void compileAsJava(EventObject evt)

    - #### Object compileFinishNormal()

    - #### void compileScript(EventObject evt, Console.SourceType st)

    - #### void componentHidden(ComponentEvent e)

    - #### void componentMoved(ComponentEvent e)

    - #### void componentResized(ComponentEvent e)

    - #### void componentShown(ComponentEvent e)

    - #### void copy(EventObject evt)

    - #### void createOutputPrintWriter(File outputFile)

    - #### void cut(EventObject evt)

    - #### void detachedOutput(EventObject evt)

    - #### void doInterrupt(EventObject evt)

    - #### @CompileStatic
      int dot(CaretEvent e)

    - #### boolean exit(EventObject evt)

    - #### void exitDesktop(EventObject evt, Object quitResponse)

    - #### void fileNewFile(EventObject evt)

    - #### void fileNewWindow(EventObject evt)

    - #### void fileOpen(EventObject evt)

    - #### boolean fileSave(EventObject evt)

    - #### boolean fileSaveAs(EventObject evt)

    - #### void find(EventObject evt)

    - #### void findNext(EventObject evt)

    - #### void findPrevious(EventObject evt)

    - #### Object finishException(Throwable t, boolean executing)

    - #### Object finishNormal(Object result, Long elapsedTime)

    - #### void focusGained(FocusEvent e)

    - #### void focusLost(FocusEvent e)

    - #### void fullStackTraces(EventObject evt)

    - #### int getConsoleId()

    - #### Object getLastResult()

    - #### void hideAndClearOutputWindow(EventObject evt)

    - #### void hideOutputWindow(EventObject evt)

    - #### void historyNext(EventObject evt)

    - #### void historyPrev(EventObject evt)

    - #### void hyperlinkUpdate(HyperlinkEvent e)

    - #### void insertString(Document doc, int offset, String text, AttributeSet attributeSet, boolean outputToFile)

    - #### void inspectAst(EventObject evt)

    - #### @CompileStatic
      void inspectCst(EventObject evt)

    - #### void inspectLast(EventObject evt)

    - #### void inspectTokens(EventObject evt)

    - #### void inspectVariables(EventObject evt)

    - #### void installInterceptor()

    - #### void invokeTextAction(Object evt, Object closure, Object area)

    - #### void largerFont(EventObject evt)

    - #### void listClasspath(EventObject evt)

    - #### int loadMaxOutputChars()

    - #### void loadScriptFile(File file)

    - #### void loopMode(EventObject evt)

    - #### static void main(Object args)

    - #### @CompileStatic
      int mark(CaretEvent e)

    - #### void newScript(ClassLoader parent, Binding binding)

    - #### static boolean notifySystemErr(int consoleId, String str)

    - #### static boolean notifySystemOut(int consoleId, String str)

    - #### void orientationVertical(EventObject evt)

    - #### void paste(EventObject evt)

    - #### void preferences(EventObject evt)

    - #### void print(EventObject evt)

    - #### void redo(EventObject evt)

    - #### void replace(EventObject evt)

    - #### void run()

    - #### @Deprecated
      @SuppressWarnings(value: removal)
      void run(JApplet applet)

      Runs the console embedded in the given applet.

      Known limitation: `javax.swing.JApplet` was removed from the JDK in Java 26 (JEP 504). Because this method's signature references that type, any metaclass introspection of `Console` (including simply creating one) fails to load on JDK 26+. This deprecated, unused overload is retained for backwards compatibility on the 4.0.x line; run the Groovy console on JDK 25 or earlier, or use a later Groovy version where this method has been removed.

      deprecated:
        applets are obsolete and the Applet API was removed in JDK 26

    - #### void run(Map defaults)

    - #### void runJava(EventObject evt)

    - #### void runScript(EventObject evt, Console.SourceType st)

    - #### void runSelectedJava(EventObject evt)

    - #### void runSelectedScript(EventObject evt, Console.SourceType st)

    - #### void saveOnRun(EventObject evt)

    - #### void selectAll(EventObject evt)

    - #### void selectBlock(EventObject evt)

    - #### Object selectFilename(Object name)

    - #### void setDirty(boolean newDirty)

    - #### void setOutputPreferences(boolean useOutputFile, File outputFile)

    - #### void setRowNumAndColNum()

    - #### void setVariable(String name, Object value)

    - #### void showAbout(EventObject evt)

    - #### void showCompilingMessage()

    - #### void showExecutingMessage()

    - #### void showMessage(String message)

    - #### void showOutputWindow(EventObject evt)

    - #### void showScriptInOutput(EventObject evt)

    - #### void showToolbar(EventObject evt)

    - #### void smallerFont(EventObject evt)

    - #### void smartHighlighter(EventObject evt)

    - #### void threadInterruption(EventObject evt)

    - #### void undo(EventObject evt)

    - #### void updateTitle()

    - #### void visualizeScriptResults(EventObject evt)