Class BaseTextPane

    • Field Detail

      • m_AnyChangeListeners

        protected Set<ChangeListener> m_AnyChangeListeners
        the listeners for any changes to the text.
    • Constructor Detail

      • BaseTextPane

        public BaseTextPane()
        Creates a new BaseTextPane. A new instance of StyledEditorKit is created and set, and the document model set to null.
      • BaseTextPane

        public BaseTextPane​(StyledDocument doc)
        Creates a new BaseTextPane, with a specified document model. A new instance of javax.swing.text.StyledEditorKit is created and set.
        Parameters:
        doc - the document model
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the member variables.
      • getParentFrame

        public Frame getParentFrame()
        Tries to determine the frame the container is part of.
        Returns:
        the parent frame if one exists or null if not
      • getParentDialog

        public Dialog getParentDialog()
        Tries to determine the dialog this panel is part of.
        Returns:
        the parent dialog if one exists or null if not
      • getParentInternalFrame

        public JInternalFrame getParentInternalFrame()
        Tries to determine the internal frame this panel is part of.
        Returns:
        the parent internal frame if one exists or null if not
      • printText

        public void printText()
        Pops up a print dialog.
      • selectFont

        public void selectFont()
        Pops up a dialog for selecting the font.
      • setTextFont

        public void setTextFont​(Font font)
        Sets the font of the text pane.
        Parameters:
        font - the font to use
      • getLineCount

        public int getLineCount()
        Returns the number of lines in the document (= # of elements).
        Returns:
        the number of lines
      • gotoLine

        public boolean gotoLine​(int line)
        Jumps to the specified line.
        Parameters:
        line - the 0-based index for the line
        Returns:
        true if successfully jumped
      • caretToLine

        public int caretToLine​(int position)
        Determines the line number for the caret position.
        Parameters:
        position - the caret position
        Returns:
        the line number, -1 if failed to determine
      • append

        public void append​(String text)
        Appends the text at the end.
        Parameters:
        text - the text to append
      • append

        public void append​(String text,
                           AttributeSet a)
        Appends the text at the end.
        Parameters:
        text - the text to append
        a - the attribute set, null if to use current
      • notifyAnyChangeListeners

        protected void notifyAnyChangeListeners()
        Notifies all listeners that some change to the text occurred.