Class TextEditor

All Implemented Interfaces:
ImageObserver, MenuContainer, Pageable, Printable, Serializable, Accessible, Scrollable

public class TextEditor extends JTextPane implements Pageable, Printable
A simple text pane that is printable and wrapping is optional.
See Also:
  • Field Details

  • Constructor Details

    • TextEditor

      public TextEditor()
      Creates a new instance of TextEditor
    • TextEditor

      public TextEditor(boolean tabsAsSpaces)
      Creates a new instance of TextEditor
    • TextEditor

      public TextEditor(boolean tabsAsSpaces, boolean multiLineTab)
      Creates a new instance of TextEditor
    • TextEditor

      public TextEditor(boolean tabsAsSpaces, boolean multiLineTab, boolean unwrapped)
      Creates a new instance of TextEditor
  • Method Details

    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class JComponent
    • getNumberOfPages

      public int getNumberOfPages()
      Specified by:
      getNumberOfPages in interface Pageable
    • getPageFormat

      public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException
      Specified by:
      getPageFormat in interface Pageable
      Throws:
      IndexOutOfBoundsException
    • getPrintable

      public Printable getPrintable(int param) throws IndexOutOfBoundsException
      Specified by:
      getPrintable in interface Pageable
      Throws:
      IndexOutOfBoundsException
    • print

      public int print(Graphics graphics, PageFormat pageFormat, int page) throws PrinterException
      Specified by:
      print in interface Printable
      Throws:
      PrinterException
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()
      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
      Overrides:
      getScrollableTracksViewportWidth in class JEditorPane
    • isMultiLineTabbed

      public boolean isMultiLineTabbed()
      Whether using the tab key indents the selected lines of code
      Returns:
      true if multiline tabbing is active
    • isOvertypeMode

      public static boolean isOvertypeMode()
      Returns:
      true if overtype mode is active, false for insert mode
    • isTabsAsSpaces

      public boolean isTabsAsSpaces()
      Returns:
      true if tabs are converted to spaces upon typing
    • isUnwrapped

      public boolean isUnwrapped()
      Returns:
      true if text wrapping is disabled
    • processKeyEvent

      protected void processKeyEvent(KeyEvent e)
      Overrides:
      processKeyEvent in class JComponent
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class JTextComponent
    • replaceSelection

      public void replaceSelection(String text)
      Overrides:
      replaceSelection in class JTextPane
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overrides:
      setBounds in class Component
    • isMultiLineTabbed

      public void isMultiLineTabbed(boolean multiLineTab)
      Parameters:
      multiLineTab - the new multiLine tab value
    • isTabsAsSpaces

      public void isTabsAsSpaces(boolean tabsAsSpaces)
      Parameters:
      tabsAsSpaces - whether tabs are converted to spaces
    • setOvertypeMode

      public void setOvertypeMode(boolean isOvertypeMode)
      Set the caret to use depending on overtype/insert mode
      Parameters:
      isOvertypeMode - the new mode; true = overtype
    • setUnwrapped

      public void setUnwrapped(boolean unwrapped)
      Parameters:
      unwrapped - the new unwrapped value