Class ConsoleTextEditor

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class ConsoleTextEditor extends JScrollPane
Component which provides a styled editor for the console.
See Also:
  • Constructor Details

    • ConsoleTextEditor

      public ConsoleTextEditor()
      Creates a styled text editor with line numbers, undo/redo support, printing support, and syntax highlighting.
  • Method Details

    • getDefaultFamily

      public String getDefaultFamily()
      Returns the preferred monospaced font family for the editor.
      Returns:
      the default font family name
    • setDefaultFamily

      public void setDefaultFamily(String defaultFamily)
      Sets the preferred monospaced font family for the editor.
      Parameters:
      defaultFamily - the font family name to use
    • getUndoManager

      public TextUndoManager getUndoManager()
      Returns the undo manager backing this editor.
      Returns:
      the editor undo manager
      Since:
      6.0.0
    • reapplyHighlighting

      public void reapplyHighlighting()
      Re-run the syntax highlighter on the full document so character attributes match the current theme. Undo recording is suppressed so this doesn't pollute the undo/redo stack. Used after undo/redo because UndoableEdits restore attributes captured at edit time, which may no longer match the active theme.
      Since:
      6.0.0
    • setShowLineNumbers

      public void setShowLineNumbers(boolean showLineNumbers)
      Shows or hides the line-number gutter.
      Parameters:
      showLineNumbers - true to show line numbers
    • setEditable

      public void setEditable(boolean editable)
      Updates whether the text editor accepts user edits.
      Parameters:
      editable - true if the editor should be editable
    • clipBoardAvailable

      public boolean clipBoardAvailable()
      Reports whether plain-text clipboard content is currently available.
      Returns:
      true if the clipboard contains a string
    • getTextEditor

      public TextEditor getTextEditor()
      Returns the wrapped text editor component.
      Returns:
      the embedded text editor
    • initActions

      protected void initActions()
      Installs actions exposed by this editor on its action map.
    • getUndoAction

      public Action getUndoAction()
      Returns the action that undoes the most recent edit.
      Returns:
      the undo action
    • getRedoAction

      public Action getRedoAction()
      Returns the action that redoes the most recently undone edit.
      Returns:
      the redo action
    • getPrintAction

      public Action getPrintAction()
      Returns the action that prints the editor content.
      Returns:
      the print action
    • enableHighLighter

      public void enableHighLighter(Class<? extends DocumentFilter> clazz)
      Replaces the current syntax highlighter document filter.
      Parameters:
      clazz - the filter type to instantiate for the current document