org.fife.ui.rtextarea
Class RTextArea

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextArea
                      extended by org.fife.ui.rtextarea.RTextArea
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable
Direct Known Subclasses:
RSyntaxTextArea

public class RTextArea
extends javax.swing.JTextArea
implements java.awt.print.Printable

An extension of JTextArea that adds the following features:

NOTE: If the background for an RTextArea is set to a color, its opaque property is set to true for performance reasons. If the background is set to an image, then the opaque property is set to false. This slows things down a little, but if it didn't happen then we would see garbage on-screen when the user scrolled through a document using the arrow keys (not the page-up/down keys though). You should never have to set the opaque property yourself; it is always done for you.

Version:
1.0
Author:
Robert Futrell
See Also:
Serialized Form

Nested Class Summary
protected  class RTextArea.RTextAreaMutableCaretEvent
          Modified from MutableCaretEvent in JTextComponent so that mouse events get fired when the user is selecting text with the mouse as well.
 
Nested classes/interfaces inherited from class javax.swing.JTextArea
javax.swing.JTextArea.AccessibleJTextArea
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BACKGROUND_IMAGE_PROPERTY
           
static int COPY_ACTION
           
static java.lang.String CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
           
static java.lang.String CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
           
static int CUT_ACTION
           
static int DELETE_ACTION
           
static java.lang.String HIGHLIGHT_CURRENT_LINE_PROPERTY
           
static int INSERT_MODE
          Constant representing insert mode.
static java.lang.String MARK_ALL_COLOR_PROPERTY
          The property fired when the "mark all" color changes.
static java.lang.String MARK_ALL_OCCURRENCES_CHANGED_PROPERTY
          The property fired when what ranges are labeled "mark all" changes.
static int OVERWRITE_MODE
          Constant representing overwrite mode.
static int PASTE_ACTION
           
static int REDO_ACTION
           
static java.lang.String ROUNDED_SELECTION_PROPERTY
           
static int SELECT_ALL_ACTION
           
static int UNDO_ACTION
           
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RTextArea()
          Constructor.
RTextArea(javax.swing.text.AbstractDocument doc)
          Constructor.
RTextArea(javax.swing.text.AbstractDocument doc, java.lang.String text, int rows, int cols)
          Constructor.
RTextArea(int textMode)
          Creates a new RTextArea.
RTextArea(int rows, int cols)
          Constructor.
RTextArea(java.lang.String text)
          Constructor.
RTextArea(java.lang.String text, int rows, int cols)
          Constructor.
 
Method Summary
 java.lang.Object addLineHighlight(int line, java.awt.Color color)
          Adds a line highlight.
 void beginAtomicEdit()
          Begins an "atomic edit."
static void beginRecordingMacro()
          Begins recording a macro.
 boolean canRedo()
          Tells whether a redo is possible
 boolean canUndo()
          Tells whether an undo is possible
protected  void configurePopupMenu(javax.swing.JPopupMenu popupMenu)
          Configures the popup menu for this text area.
 void convertSpacesToTabs()
          Converts all instances of a number of spaces equal to a tab size into a tab in this text area.
 void convertTabsToSpaces()
          Converts all instances of a tab into a number of spaces equivalent to a tab in this text area.
protected  javax.swing.text.Document createDefaultModel()
          Creates the default implementation of the model to be used at construction if one isn't explicitly given.
protected  org.fife.ui.rtextarea.RTextAreaBase.RTAMouseListener createMouseListener()
          Returns the caret event/mouse listener for RTextAreas.
protected  javax.swing.JPopupMenu createPopupMenu()
          Creates the right-click popup menu.
protected  javax.swing.JMenuItem createPopupMenuItem(javax.swing.Action a)
          Creates and configures a menu item for used in the popup menu.
protected  RTextAreaUI createRTextAreaUI()
          Returns the a real UI to install on this text area.
protected  RUndoManager createUndoManager()
          Creates an undo manager for use in this text area.
 void discardAllEdits()
          Removes all undoable edits from this document's undo manager.
 void endAtomicEdit()
          Completes an "atomic" edit.
static void endRecordingMacro()
          Ends recording a macro.
protected  void fireCaretUpdate(javax.swing.event.CaretEvent e)
          Notifies all listeners that a caret change has occurred.
protected  void forceCurrentLineHighlightRepaint()
          Forces the current line highlight to be repainted.
static RecordableTextAction getAction(int action)
          Provides a way to gain access to the editor actions on the right-click popup menu.
 java.awt.Color getBackground()
          Returns the java.awt.Color used as the background color for this text area.
 java.awt.Image getBackgroundImage()
          Returns the image currently used for the background.
 java.lang.Object getBackgroundObject()
          Returns the Object representing the background for all documents in this tabbed pane; either a java.awt.Color or a java.lang.Image containing the image used as the background for this text area.
 int getCaretLineNumber()
          Gets the line number that the caret is on.
 int getCaretOffsetFromLineStart()
          Gets the position from the beginning of the current line that the caret is on.
 java.awt.Color getCurrentLineHighlightColor()
          Returns the color being used to highlight the current line.
static Macro getCurrentMacro()
          Returns the macro currently stored in this RTextArea.
static java.awt.Color getDefaultCaretColor()
          Returns the default caret color.
static java.awt.Color getDefaultCurrentLineHighlightColor()
          Returns the "default" color for highlighting the current line.
static java.awt.Font getDefaultFont()
          Returns the default font for text areas.
static java.awt.Color getDefaultForeground()
          Returns the default foreground color for text in this text area.
static java.awt.Color getDefaultMarginLineColor()
          Returns the default color for the margin line.
static int getDefaultMarginLinePosition()
          Returns the default margin line position.
static java.awt.Color getDefaultMarkAllHighlightColor()
          Returns the default color used for "mark all."
static int getDefaultTabSize()
          Returns the default tab size, in spaces.
 boolean getFadeCurrentLineHighlight()
          Returns whether the current line highlight is faded.
 boolean getHighlightCurrentLine()
          Returns whether or not the current line is highlighted.
static IconGroup getIconGroup()
          Returns the icon group being used for the actions of this text area.
 int getLineEndOffsetOfCurrentLine()
          Returns the offset of the last character of the line that the caret is on.
 int getLineHeight()
          Returns the height of a line of text in this text area.
 int getLineStartOffsetOfCurrentLine()
          Returns the offset of the first character of the line that the caret is on.
 java.awt.Color getMarginLineColor()
          Returns the color used to paint the margin line.
 int getMarginLinePixelLocation()
          Returns the margin line position (in pixels) from the left-hand side of the text area.
 int getMarginLinePosition()
          Returns the margin line position (which is the number of 'm' widths in the current font the margin line is over).
 java.awt.Color getMarkAllHighlightColor()
          Returns the color used in "mark all."
 int getMaxAscent()
          Returns the maximum ascent of all fonts used in this text area.
 javax.swing.JPopupMenu getPopupMenu()
          Returns the popup menu for this component, lazily creating it if necessary.
 boolean getRoundedSelectionEdges()
          Returns whether selection edges are rounded in this text area.
static java.lang.String getSelectedOccurrenceText()
          Returns the text last selected and used in a Ctrl+K operation.
 boolean getTabsEmulated()
          Returns whether or not tabs are emulated with spaces (i.e., "soft" tabs).
 int getTextMode()
          Returns the text mode this editor pane is currently in.
 ToolTipSupplier getToolTipSupplier()
          Returns the tool tip supplier.
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Returns the tooltip to display for a mouse event at the given location.
protected  void handleReplaceSelection(java.lang.String content)
          Does the actual dirty-work of replacing the selected text in this text area (i.e., in its document).
protected  void init()
          Initializes this text area.
 boolean isMarginLineEnabled()
          Returns whether or not the margin line is being painted.
static boolean isOSX()
          Returns whether the OS we're running on is OS X.
static boolean isRecordingMacro()
          Returns whether or not a macro is being recorded.
static void loadMacro(Macro macro)
          Loads a macro to be used by all RTextAreas in the current application.
protected  void paintComponent(java.awt.Graphics g)
          Paints the text area.
 void paste()
          
 void playbackLastMacro()
          "Plays back" the last recorded macro in this text area.
protected  void possiblyUpdateCurrentLineHighlightLocation()
          Updates the current line highlight location.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
          Method called when it's time to print this badboy (the old-school, AWT way).
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
          Overridden so we can tell when the text area is resized and update the current-line highlight, if necessary (i.e., if it is enabled and if lineWrap is enabled.
 void read(java.io.Reader in, java.lang.Object desc)
          We override this method because the super version gives us an entirely new Document, thus requiring us to re-attach our Undo manager.
 void redoLastAction()
          Attempt to redo the last action.
 void removeAllLineHighlights()
          Removes all line highlights.
 void removeLineHighlight(java.lang.Object tag)
          Removes a line highlight.
 void replaceRange(java.lang.String str, int start, int end)
          Replaces text from the indicated start to end position with the new text specified.
 void replaceSelection(java.lang.String text)
          This method overrides JTextComponent's replaceSelection, so that if textMode is OVERWRITE_MODE, it actually overwrites.
static void setActionProperties(int action, java.lang.String name, char mnemonic, javax.swing.KeyStroke accelerator)
          Sets the properties of one of the actions this text area owns.
static void setActionProperties(int action, java.lang.String name, java.lang.Integer mnemonic, javax.swing.KeyStroke accelerator)
          Sets the properties of one of the actions this text area owns.
 void setBackground(java.awt.Color bg)
          Sets the background color of this text editor.
 void setBackgroundImage(java.awt.Image image)
          Sets this image as the background image.
 void setBackgroundObject(java.lang.Object newBackground)
          Makes the background into this Object.
 void setCaret(javax.swing.text.Caret caret)
          Sets the caret to use in this text area.
 void setCaretStyle(int mode, int style)
          Sets the style of caret used when in insert or overwrite mode.
 void setCurrentLineHighlightColor(java.awt.Color color)
          Sets the color to use to highlight the current line.
 void setDocument(javax.swing.text.Document document)
          Sets the document used by this text area.
 void setFadeCurrentLineHighlight(boolean fade)
          Sets whether the current line highlight should have a "fade" effect.
 void setFont(java.awt.Font font)
          Sets the font for this text area.
 void setHighlightCurrentLine(boolean highlight)
          Sets whether or not the current line is highlighted.
static void setIconGroup(IconGroup group)
          Sets the path in which to find images to associate with the editor's actions.
 void setLineWrap(boolean wrap)
          Sets whether or not word wrap is enabled.
 void setMargin(java.awt.Insets insets)
          Overridden to update the current line highlight location.
 void setMarginLineColor(java.awt.Color color)
          Sets the color used to paint the margin line.
 void setMarginLineEnabled(boolean enabled)
          Enables or disables the margin line.
 void setMarginLinePosition(int size)
          Sets the number of 'm' widths the margin line is over.
 void setMarkAllHighlightColor(java.awt.Color color)
          Sets the color used for "mark all."
 void setPopupMenu(javax.swing.JPopupMenu popupMenu)
          Sets the popup menu used by this text area.
 void setRoundedSelectionEdges(boolean rounded)
          Sets whether the edges of selections are rounded in this text area.
protected  void setRTextAreaUI(RTextAreaUI ui)
          Sets the UI for this RTextArea.
static void setSelectedOccurrenceText(java.lang.String text)
          Sets the text last selected/Ctrl+K'd in an RTextArea.
 void setTabsEmulated(boolean areEmulated)
          Changes whether or not tabs should be emulated with spaces (i.e., soft tabs).
 void setTabSize(int size)
          Workaround, since in JDK1.4 it appears that setTabSize() doesn't work for a JTextArea unless you use the constructor specifying the number of rows and columns...
 void setTextMode(int mode)
          Sets the text mode for this editor pane.
 void setToolTipSupplier(ToolTipSupplier supplier)
          Sets the tool tip supplier.
 void setUI(javax.swing.plaf.TextUI ui)
          Sets the UI used by this text area.
 void undoLastAction()
          Attempt to undo an "action" done in this text area.
protected  void updateMarginLineX()
          This is here so subclasses such as RSyntaxTextArea that have multiple fonts can define exactly what it means, for example, for the margin line to be "80 characters" over.
 int yForLine(int line)
          Returns the y-coordinate of the specified line.
 int yForLineContaining(int offs)
          Returns the y-coordinate of the line containing an offset.
 
Methods inherited from class javax.swing.JTextArea
append, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, setColumns, setRows, setWrapStyleWord
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, processInputMethodEvent, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INSERT_MODE

public static final int INSERT_MODE
Constant representing insert mode.

See Also:
setCaretStyle(int, int), Constant Field Values

OVERWRITE_MODE

public static final int OVERWRITE_MODE
Constant representing overwrite mode.

See Also:
setCaretStyle(int, int), Constant Field Values

MARK_ALL_COLOR_PROPERTY

public static final java.lang.String MARK_ALL_COLOR_PROPERTY
The property fired when the "mark all" color changes.

See Also:
Constant Field Values

MARK_ALL_OCCURRENCES_CHANGED_PROPERTY

public static final java.lang.String MARK_ALL_OCCURRENCES_CHANGED_PROPERTY
The property fired when what ranges are labeled "mark all" changes.

See Also:
Constant Field Values

COPY_ACTION

public static final int COPY_ACTION
See Also:
Constant Field Values

CUT_ACTION

public static final int CUT_ACTION
See Also:
Constant Field Values

DELETE_ACTION

public static final int DELETE_ACTION
See Also:
Constant Field Values

PASTE_ACTION

public static final int PASTE_ACTION
See Also:
Constant Field Values

REDO_ACTION

public static final int REDO_ACTION
See Also:
Constant Field Values

SELECT_ALL_ACTION

public static final int SELECT_ALL_ACTION
See Also:
Constant Field Values

UNDO_ACTION

public static final int UNDO_ACTION
See Also:
Constant Field Values

BACKGROUND_IMAGE_PROPERTY

public static final java.lang.String BACKGROUND_IMAGE_PROPERTY
See Also:
Constant Field Values

CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY

public static final java.lang.String CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
See Also:
Constant Field Values

CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY

public static final java.lang.String CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
See Also:
Constant Field Values

HIGHLIGHT_CURRENT_LINE_PROPERTY

public static final java.lang.String HIGHLIGHT_CURRENT_LINE_PROPERTY
See Also:
Constant Field Values

ROUNDED_SELECTION_PROPERTY

public static final java.lang.String ROUNDED_SELECTION_PROPERTY
See Also:
Constant Field Values
Constructor Detail

RTextArea

public RTextArea()
Constructor.


RTextArea

public RTextArea(javax.swing.text.AbstractDocument doc)
Constructor.

Parameters:
doc - The document for the editor.

RTextArea

public RTextArea(java.lang.String text)
Constructor.

Parameters:
text - The initial text to display.

RTextArea

public RTextArea(int rows,
                 int cols)
Constructor.

Parameters:
rows - The number of rows to display.
cols - The number of columns to display.
Throws:
java.lang.IllegalArgumentException - If either rows or cols is negative.

RTextArea

public RTextArea(java.lang.String text,
                 int rows,
                 int cols)
Constructor.

Parameters:
text - The initial text to display.
rows - The number of rows to display.
cols - The number of columns to display.
Throws:
java.lang.IllegalArgumentException - If either rows or cols is negative.

RTextArea

public RTextArea(javax.swing.text.AbstractDocument doc,
                 java.lang.String text,
                 int rows,
                 int cols)
Constructor.

Parameters:
doc - The document for the editor.
text - The initial text to display.
rows - The number of rows to display.
cols - The number of columns to display.
Throws:
java.lang.IllegalArgumentException - If either rows or cols is negative.

RTextArea

public RTextArea(int textMode)
Creates a new RTextArea.

Parameters:
textMode - Either INSERT_MODE or OVERWRITE_MODE.
Method Detail

addLineHighlight

public java.lang.Object addLineHighlight(int line,
                                         java.awt.Color color)
                                  throws javax.swing.text.BadLocationException
Adds a line highlight.

Parameters:
line - The line to highlight. This is zero-based.
color - The color to highlight the line with.
Throws:
javax.swing.text.BadLocationException - If line is an invalid line number.
See Also:
removeLineHighlight(Object), removeAllLineHighlights()

beginAtomicEdit

public void beginAtomicEdit()
Begins an "atomic edit." All text editing operations between this call and the next call to endAtomicEdit() will be treated as a single operation by the undo manager.

Using this method should be done with great care. You should probably wrap the call to endAtomicEdit() in a finally block:

 textArea.beginAtomicEdit();
 try {
    // Do editing
 } finally {
    textArea.endAtomicEdit();
 }
 

See Also:
endAtomicEdit()

beginRecordingMacro

public static void beginRecordingMacro()
Begins recording a macro. After this method is called, all input/caret events, etc. are recorded until endMacroRecording is called. If this method is called but the text component is already recording a macro, nothing happens (but the macro keeps recording).

See Also:
isRecordingMacro(), endRecordingMacro()

canUndo

public boolean canUndo()
Tells whether an undo is possible

See Also:
canRedo(), undoLastAction()

canRedo

public boolean canRedo()
Tells whether a redo is possible

See Also:
canUndo(), redoLastAction()

configurePopupMenu

protected void configurePopupMenu(javax.swing.JPopupMenu popupMenu)
Configures the popup menu for this text area. This method is called right before it is displayed, so a hosting application can do any custom configuration (configuring actions, adding/removing items, etc.).

The default implementation does nothing.

If you set the popup menu via setPopupMenu(JPopupMenu), you will want to override this method, especially if you removed any of the menu items in the default popup menu.

Parameters:
popupMenu - The popup menu. This will never be null.
See Also:
createPopupMenu(), setPopupMenu(JPopupMenu)

createDefaultModel

protected javax.swing.text.Document createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given. A new instance of RDocument is returned.

Overrides:
createDefaultModel in class javax.swing.JTextArea
Returns:
The default document.

createMouseListener

protected org.fife.ui.rtextarea.RTextAreaBase.RTAMouseListener createMouseListener()
Returns the caret event/mouse listener for RTextAreas.

Returns:
The caret event/mouse listener.

createPopupMenu

protected javax.swing.JPopupMenu createPopupMenu()
Creates the right-click popup menu. Subclasses can override this method to replace or augment the popup menu returned.

Returns:
The popup menu.
See Also:
setPopupMenu(JPopupMenu), configurePopupMenu(JPopupMenu), createPopupMenuItem(Action)

createPopupMenuItem

protected javax.swing.JMenuItem createPopupMenuItem(javax.swing.Action a)
Creates and configures a menu item for used in the popup menu.

Parameters:
a - The action for the menu item.
Returns:
The menu item.
See Also:
createPopupMenu()

createRTextAreaUI

protected RTextAreaUI createRTextAreaUI()
Returns the a real UI to install on this text area.

Returns:
The UI.

createUndoManager

protected RUndoManager createUndoManager()
Creates an undo manager for use in this text area.

Returns:
The undo manager.

discardAllEdits

public void discardAllEdits()
Removes all undoable edits from this document's undo manager. This method also makes the undo/redo actions disabled.


endAtomicEdit

public void endAtomicEdit()
Completes an "atomic" edit.

See Also:
beginAtomicEdit()

endRecordingMacro

public static void endRecordingMacro()
Ends recording a macro. If this method is called but the text component is not recording a macro, nothing happens.

See Also:
isRecordingMacro(), beginRecordingMacro()

fireCaretUpdate

protected void fireCaretUpdate(javax.swing.event.CaretEvent e)
Notifies all listeners that a caret change has occurred.

Overrides:
fireCaretUpdate in class javax.swing.text.JTextComponent
Parameters:
e - The caret event.

getAction

public static RecordableTextAction getAction(int action)
Provides a way to gain access to the editor actions on the right-click popup menu. This way you can make toolbar/menu bar items use the actual actions used by all RTextAreas, so that icons stay synchronized and you don't have to worry about enabling/disabling them yourself.

Keep in mind that these actions are shared across all instances of RTextArea, so a change to any action returned by this method is global across all RTextArea editors in your application.

Parameters:
action - The action to retrieve, such as CUT_ACTION. If the action name is invalid, null is returned.
Returns:
The action, or null if an invalid action is requested.

getCurrentMacro

public static Macro getCurrentMacro()
Returns the macro currently stored in this RTextArea. Since macros are shared, all RTextAreas in the currently- running application are using this macro.

Returns:
The current macro, or null if no macro has been recorded/loaded.
See Also:
loadMacro(Macro)

getDefaultMarkAllHighlightColor

public static final java.awt.Color getDefaultMarkAllHighlightColor()
Returns the default color used for "mark all."

Returns:
The color.
See Also:
getMarkAllHighlightColor(), setMarkAllHighlightColor(Color)

getIconGroup

public static IconGroup getIconGroup()
Returns the icon group being used for the actions of this text area.

Returns:
The icon group.
See Also:
setIconGroup(IconGroup)

getMarkAllHighlightColor

public java.awt.Color getMarkAllHighlightColor()
Returns the color used in "mark all."

Returns:
The color.
See Also:
setMarkAllHighlightColor(Color)

getMaxAscent

public int getMaxAscent()
Returns the maximum ascent of all fonts used in this text area. In the case of a standard RTextArea, this is simply the ascent of the current font.

This value could be useful, for example, to implement a line-numbering scheme.

Returns:
The ascent of the current font.

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()
Returns the popup menu for this component, lazily creating it if necessary.

Returns:
The popup menu.
See Also:
createPopupMenu(), setPopupMenu(JPopupMenu)

getSelectedOccurrenceText

public static java.lang.String getSelectedOccurrenceText()
Returns the text last selected and used in a Ctrl+K operation.

Returns:
The text, or null if none.
See Also:
setSelectedOccurrenceText(String)

getTextMode

public final int getTextMode()
Returns the text mode this editor pane is currently in.

Returns:
Either INSERT_MODE or OVERWRITE_MODE.
See Also:
setTextMode(int)

getToolTipSupplier

public ToolTipSupplier getToolTipSupplier()
Returns the tool tip supplier.

Returns:
The tool tip supplier, or null if one isn't installed.
See Also:
setToolTipSupplier(ToolTipSupplier)

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Returns the tooltip to display for a mouse event at the given location. This method is overridden to check for a ToolTipSupplier; if there is one installed, it is queried for tool tip text before using the super class's implementation of this method.

Overrides:
getToolTipText in class javax.swing.text.JTextComponent
Parameters:
e - The mouse event.
Returns:
The tool tip text, or null if none.
See Also:
getToolTipSupplier(), setToolTipSupplier(ToolTipSupplier)

handleReplaceSelection

protected void handleReplaceSelection(java.lang.String content)
Does the actual dirty-work of replacing the selected text in this text area (i.e., in its document). This method provides a hook for subclasses to handle this in a different way.

Parameters:
content - The content to add.

init

protected void init()
Initializes this text area.


isRecordingMacro

public static boolean isRecordingMacro()
Returns whether or not a macro is being recorded.

Returns:
Whether or not a macro is being recorded.
See Also:
beginRecordingMacro(), endRecordingMacro()

loadMacro

public static void loadMacro(Macro macro)
Loads a macro to be used by all RTextAreas in the current application.

Parameters:
macro - The macro to load.
See Also:
getCurrentMacro()

paste

public void paste()

Overrides:
paste in class javax.swing.text.JTextComponent

playbackLastMacro

public void playbackLastMacro()
"Plays back" the last recorded macro in this text area.


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
Method called when it's time to print this badboy (the old-school, AWT way).

Specified by:
print in interface java.awt.print.Printable
Parameters:
g - The context into which the page is drawn.
pageFormat - The size and orientation of the page being drawn.
pageIndex - The zero based index of the page to be drawn.

read

public void read(java.io.Reader in,
                 java.lang.Object desc)
          throws java.io.IOException
We override this method because the super version gives us an entirely new Document, thus requiring us to re-attach our Undo manager. With this version we just replace the text.

Overrides:
read in class javax.swing.text.JTextComponent
Throws:
java.io.IOException

redoLastAction

public void redoLastAction()
Attempt to redo the last action.

See Also:
undoLastAction()

removeAllLineHighlights

public void removeAllLineHighlights()
Removes all line highlights.

See Also:
removeLineHighlight(Object)

removeLineHighlight

public void removeLineHighlight(java.lang.Object tag)
Removes a line highlight.

Parameters:
tag - The tag of the line highlight to remove.
See Also:
removeAllLineHighlights(), addLineHighlight(int, Color)

replaceRange

public void replaceRange(java.lang.String str,
                         int start,
                         int end)
Replaces text from the indicated start to end position with the new text specified. Does nothing if the model is null. Simply does a delete if the new string is null or empty.

This method is thread safe, although most Swing methods are not.

This method is overridden so that our Undo manager remembers it as a single operation (it has trouble with this, especially for RSyntaxTextArea and the "auto-indent" feature).

Overrides:
replaceRange in class javax.swing.JTextArea
Parameters:
str - the text to use as the replacement
start - the start position >= 0
end - the end position >= start
Throws:
java.lang.IllegalArgumentException - if part of the range is an invalid position in the model
See Also:
JTextArea.insert(String, int), replaceRange(String, int, int)

replaceSelection

public void replaceSelection(java.lang.String text)
This method overrides JTextComponent's replaceSelection, so that if textMode is OVERWRITE_MODE, it actually overwrites.

Overrides:
replaceSelection in class javax.swing.text.JTextComponent
Parameters:
text - The content to replace the selection with.

setActionProperties

public static void setActionProperties(int action,
                                       java.lang.String name,
                                       char mnemonic,
                                       javax.swing.KeyStroke accelerator)
Sets the properties of one of the actions this text area owns.

Parameters:
action - The action to modify; for example, CUT_ACTION.
name - The new name for the action.
mnemonic - The new mnemonic for the action.
accelerator - The new accelerator key for the action.

setActionProperties

public static void setActionProperties(int action,
                                       java.lang.String name,
                                       java.lang.Integer mnemonic,
                                       javax.swing.KeyStroke accelerator)
Sets the properties of one of the actions this text area owns.

Parameters:
action - The action to modify; for example, CUT_ACTION.
name - The new name for the action.
mnemonic - The new mnemonic for the action.
accelerator - The new accelerator key for the action.

setCaret

public void setCaret(javax.swing.text.Caret caret)
Sets the caret to use in this text area. It is strongly encouraged to use ConfigurableCarets (which is used by default), or a subclass, since they know how to render themselves differently when the user toggles between insert and overwrite modes.

Overrides:
setCaret in class javax.swing.text.JTextComponent
Parameters:
caret - The caret to use. If this is not an instance of ConfigurableCaret, an exception is thrown.
Throws:
java.lang.IllegalArgumentException - If the specified caret is not an ConfigurableCaret.
See Also:
setCaretStyle(int, int)

setCaretStyle

public void setCaretStyle(int mode,
                          int style)
Sets the style of caret used when in insert or overwrite mode.

Parameters:
mode - Either INSERT_MODE or OVERWRITE_MODE.
style - The style for the caret (such as ConfigurableCaret.VERTICAL_LINE_STYLE).
See Also:
ConfigurableCaret

setDocument

public void setDocument(javax.swing.text.Document document)
Sets the document used by this text area.

Overrides:
setDocument in class javax.swing.text.JTextComponent
Parameters:
document - The new document to use.
Throws:
java.lang.IllegalArgumentException - If the document is not an instance of RDocument.

setIconGroup

public static void setIconGroup(IconGroup group)
Sets the path in which to find images to associate with the editor's actions. The path MUST contain the following images (with the appropriate extension as defined by the icon group):
If any of the above images don't exist, the corresponding action will not have an icon.

Parameters:
group - The icon group to load.
See Also:
getIconGroup()

setMarkAllHighlightColor

public void setMarkAllHighlightColor(java.awt.Color color)
Sets the color used for "mark all." This fires a property change of type MARK_ALL_COLOR_PROPERTY.

Parameters:
color - The color to use for "mark all."
See Also:
getMarkAllHighlightColor()

setPopupMenu

public void setPopupMenu(javax.swing.JPopupMenu popupMenu)
Sets the popup menu used by this text area.

If you set the popup menu with this method, you'll want to consider also overriding configurePopupMenu(JPopupMenu), especially if you removed any of the default menu items.

Parameters:
popupMenu - The popup menu. If this is null, no popup menu will be displayed.
See Also:
getPopupMenu(), configurePopupMenu(JPopupMenu)

setRoundedSelectionEdges

public void setRoundedSelectionEdges(boolean rounded)
Sets whether the edges of selections are rounded in this text area. This method fires a property change of type ROUNDED_SELECTION_PROPERTY.

Parameters:
rounded - Whether selection edges should be rounded.
See Also:
getRoundedSelectionEdges()

setSelectedOccurrenceText

public static void setSelectedOccurrenceText(java.lang.String text)
Sets the text last selected/Ctrl+K'd in an RTextArea. This text will be searched for in subsequent Ctrl+K/Ctrl+Shift+K actions (Cmd+K on OS X).

Since the selected occurrence actions are built into RTextArea, applications usually do not have to call this method directly, but can choose to do so if they wish (for example, if they wish to set this value when the user does a search via a Find dialog).

Parameters:
text - The selected text.
See Also:
getSelectedOccurrenceText()

setTextMode

public void setTextMode(int mode)
Sets the text mode for this editor pane. If the currently installed caret is an instance of ConfigurableCaret, it will be automatically updated to render itself appropriately for the new text mode.

Parameters:
mode - Either INSERT_MODE or OVERWRITE_MODE.
See Also:
getTextMode()

setToolTipSupplier

public void setToolTipSupplier(ToolTipSupplier supplier)
Sets the tool tip supplier.

Parameters:
supplier - The new tool tip supplier, or null if there is to be no supplier.
See Also:
getToolTipSupplier()

setUI

public final void setUI(javax.swing.plaf.TextUI ui)
Sets the UI used by this text area. This is overridden so only the right-click popup menu's UI is updated. The look and feel of an RTextArea is independent of the Java Look and Feel, and so this method does not change the text area itself. Subclasses (such as RSyntaxTextArea can call setRTextAreaUI if they wish to install a new UI.

Overrides:
setUI in class javax.swing.text.JTextComponent
Parameters:
ui - This parameter is ignored.

undoLastAction

public void undoLastAction()
Attempt to undo an "action" done in this text area.

See Also:
redoLastAction()

convertSpacesToTabs

public void convertSpacesToTabs()
Converts all instances of a number of spaces equal to a tab size into a tab in this text area.

See Also:
convertTabsToSpaces(), getTabsEmulated(), setTabsEmulated(boolean)

convertTabsToSpaces

public void convertTabsToSpaces()
Converts all instances of a tab into a number of spaces equivalent to a tab in this text area.

See Also:
convertSpacesToTabs(), getTabsEmulated(), setTabsEmulated(boolean)

forceCurrentLineHighlightRepaint

protected void forceCurrentLineHighlightRepaint()
Forces the current line highlight to be repainted. This hack is necessary for those situations when the view (appearance) changes but the caret's location hasn't (and thus the current line highlight coordinates won't get changed). Examples of this are when word wrap is toggled and when syntax styles are changed in an RSyntaxTextArea.


getBackground

public final java.awt.Color getBackground()
Returns the java.awt.Color used as the background color for this text area. If a java.awt.Image image is currently being used instead, null is returned.

Overrides:
getBackground in class java.awt.Component
Returns:
The current background color, or null if an image is currently the background.

getBackgroundImage

public final java.awt.Image getBackgroundImage()
Returns the image currently used for the background. If the current background is currently a java.awt.Color and not a java.awt.Image, then null is returned.

Returns:
A java.awt.Image used for the background, or null if the background is not an image.
See Also:
setBackgroundImage(java.awt.Image)

getBackgroundObject

public final java.lang.Object getBackgroundObject()
Returns the Object representing the background for all documents in this tabbed pane; either a java.awt.Color or a java.lang.Image containing the image used as the background for this text area.

Returns:
The Object used for the background.
See Also:
setBackgroundObject(Object newBackground)

getCaretLineNumber

public final int getCaretLineNumber()
Gets the line number that the caret is on.

Returns:
The zero-based line number that the caret is on.

getCaretOffsetFromLineStart

public final int getCaretOffsetFromLineStart()
Gets the position from the beginning of the current line that the caret is on.

Returns:
The zero-based position from the beginning of the current line that the caret is on.

getCurrentLineHighlightColor

public java.awt.Color getCurrentLineHighlightColor()
Returns the color being used to highlight the current line. Note that if highlighting the current line is turned off, you will not be seeing this highlight.

Returns:
The color being used to highlight the current line.
See Also:
getHighlightCurrentLine(), setHighlightCurrentLine(boolean), setCurrentLineHighlightColor(java.awt.Color)

getDefaultCaretColor

public static final java.awt.Color getDefaultCaretColor()
Returns the default caret color.

Returns:
The default caret color.

getDefaultCurrentLineHighlightColor

public static final java.awt.Color getDefaultCurrentLineHighlightColor()
Returns the "default" color for highlighting the current line. Note that this color was chosen only because it looks nice (to me) against a white background.

Returns:
The default color for highlighting the current line.

getDefaultFont

public static final java.awt.Font getDefaultFont()
Returns the default font for text areas.

Returns:
The default font.

getDefaultForeground

public static final java.awt.Color getDefaultForeground()
Returns the default foreground color for text in this text area.

Returns:
The default foreground color.

getDefaultMarginLineColor

public static final java.awt.Color getDefaultMarginLineColor()
Returns the default color for the margin line.

Returns:
The default margin line color.
See Also:
getMarginLineColor(), setMarginLineColor(Color)

getDefaultMarginLinePosition

public static final int getDefaultMarginLinePosition()
Returns the default margin line position.

Returns:
The default margin line position.
See Also:
getMarginLinePosition(), setMarginLinePosition(int)

getDefaultTabSize

public static final int getDefaultTabSize()
Returns the default tab size, in spaces.

Returns:
The default tab size.

getFadeCurrentLineHighlight

public boolean getFadeCurrentLineHighlight()
Returns whether the current line highlight is faded.

Returns:
Whether the current line highlight is faded.
See Also:
setFadeCurrentLineHighlight(boolean)

getHighlightCurrentLine

public boolean getHighlightCurrentLine()
Returns whether or not the current line is highlighted.

Returns:
Whether or the current line is highlighted.
See Also:
setHighlightCurrentLine(boolean), getCurrentLineHighlightColor(), setCurrentLineHighlightColor(java.awt.Color)

getLineEndOffsetOfCurrentLine

public final int getLineEndOffsetOfCurrentLine()
Returns the offset of the last character of the line that the caret is on.

Returns:
The last offset of the line that the caret is currently on.

getLineHeight

public int getLineHeight()
Returns the height of a line of text in this text area.

Returns:
The height of a line of text.

getLineStartOffsetOfCurrentLine

public final int getLineStartOffsetOfCurrentLine()
Returns the offset of the first character of the line that the caret is on.

Returns:
The first offset of the line that the caret is currently on.

getMarginLineColor

public java.awt.Color getMarginLineColor()
Returns the color used to paint the margin line.

Returns:
The margin line color.
See Also:
setMarginLineColor(Color)

getMarginLinePixelLocation

public int getMarginLinePixelLocation()
Returns the margin line position (in pixels) from the left-hand side of the text area.

Returns:
The margin line position.
See Also:
getDefaultMarginLinePosition(), setMarginLinePosition(int)

getMarginLinePosition

public int getMarginLinePosition()
Returns the margin line position (which is the number of 'm' widths in the current font the margin line is over).

Returns:
The margin line position.
See Also:
getDefaultMarginLinePosition(), setMarginLinePosition(int)

getRoundedSelectionEdges

public boolean getRoundedSelectionEdges()
Returns whether selection edges are rounded in this text area.

Returns:
Whether selection edges are rounded.
See Also:
setRoundedSelectionEdges(boolean)

getTabsEmulated

public boolean getTabsEmulated()
Returns whether or not tabs are emulated with spaces (i.e., "soft" tabs).

Returns:
true if tabs are emulated with spaces; false if they aren't.
See Also:
setTabsEmulated(boolean)

isMarginLineEnabled

public boolean isMarginLineEnabled()
Returns whether or not the margin line is being painted.

Returns:
Whether or not the margin line is being painted.
See Also:
setMarginLineEnabled(boolean)

isOSX

public static boolean isOSX()
Returns whether the OS we're running on is OS X.

Returns:
Whether the OS we're running on is OS X.

paintComponent

protected void paintComponent(java.awt.Graphics g)
Paints the text area.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - The graphics context with which to paint.

possiblyUpdateCurrentLineHighlightLocation

protected void possiblyUpdateCurrentLineHighlightLocation()
Updates the current line highlight location.


processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
Overridden so we can tell when the text area is resized and update the current-line highlight, if necessary (i.e., if it is enabled and if lineWrap is enabled.

Overrides:
processComponentEvent in class java.awt.Component
Parameters:
e - The component event about to be sent to all registered ComponentListeners.

setBackground

public void setBackground(java.awt.Color bg)
Sets the background color of this text editor. Note that this is equivalent to calling setBackgroundObject(bg). NOTE: the opaque property is set to true when the background is set to a color (by this method). When an image is used for the background, opaque is set to false. This is because we perform better when setOpaque is true, but if we use an image for the background when opaque is true, we get on-screen garbage when the user scrolls via the arrow keys. Thus we need setOpaque to be false in that case.

You never have to change the opaque property yourself; it is always done for you.

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
bg - The color to use as the background color.

setBackgroundImage

public void setBackgroundImage(java.awt.Image image)
Sets this image as the background image. This method fires a property change event of type BACKGROUND_IMAGE_PROPERTY.

NOTE: the opaque property is set to true when the background is set to a color. When an image is used for the background (by this method), opaque is set to false. This is because we perform better when setOpaque is true, but if we use an image for the background when opaque is true, we get on-screen garbage when the user scrolls via the arrow keys. Thus we need setOpaque to be false in that case.

You never have to change the opaque property yourself; it is always done for you.

Parameters:
image - The image to use as this text area's background.
See Also:
getBackgroundImage()

setBackgroundObject

public void setBackgroundObject(java.lang.Object newBackground)
Makes the background into this Object.

Parameters:
newBackground - The java.awt.Color or java.awt.Image object. If newBackground is not either of these, the background is set to plain white.

setCurrentLineHighlightColor

public void setCurrentLineHighlightColor(java.awt.Color color)
Sets the color to use to highlight the current line. Note that if highlighting the current line is turned off, you will not be able to see this highlight. This method fires a property change of type CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY.

Parameters:
color - The color to use to highlight the current line.
Throws:
java.lang.NullPointerException - if color is null.
See Also:
getHighlightCurrentLine(), setHighlightCurrentLine(boolean), getCurrentLineHighlightColor()

setFadeCurrentLineHighlight

public void setFadeCurrentLineHighlight(boolean fade)
Sets whether the current line highlight should have a "fade" effect. This method fires a property change event of type CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY.

Parameters:
fade - Whether the fade effect should be enabled.
See Also:
getFadeCurrentLineHighlight()

setFont

public void setFont(java.awt.Font font)
Sets the font for this text area. This is overridden only so that we can update the size of the "current line highlight" and the location of the "margin line," if necessary.

Overrides:
setFont in class javax.swing.JTextArea
Parameters:
font - The font to use for this text component.

setHighlightCurrentLine

public void setHighlightCurrentLine(boolean highlight)
Sets whether or not the current line is highlighted. This method fires a property change of type HIGHLIGHT_CURRENT_LINE_PROPERTY.

Parameters:
highlight - Whether or not to highlight the current line.
See Also:
getHighlightCurrentLine(), getCurrentLineHighlightColor(), setCurrentLineHighlightColor(java.awt.Color)

setLineWrap

public void setLineWrap(boolean wrap)
Sets whether or not word wrap is enabled. This is overridden so that the "current line highlight" gets updated if it needs to be.

Overrides:
setLineWrap in class javax.swing.JTextArea
Parameters:
wrap - Whether or not word wrap should be enabled.

setMargin

public void setMargin(java.awt.Insets insets)
Overridden to update the current line highlight location.

Overrides:
setMargin in class javax.swing.text.JTextComponent
Parameters:
insets - The new insets.

setMarginLineColor

public void setMarginLineColor(java.awt.Color color)
Sets the color used to paint the margin line.

Parameters:
color - The new margin line color.
See Also:
getDefaultMarginLineColor(), getMarginLineColor()

setMarginLineEnabled

public void setMarginLineEnabled(boolean enabled)
Enables or disables the margin line.

Parameters:
enabled - Whether or not the margin line should be enabled.
See Also:
isMarginLineEnabled()

setMarginLinePosition

public void setMarginLinePosition(int size)
Sets the number of 'm' widths the margin line is over.

Parameters:
size - The margin size. #see #getDefaultMarginLinePosition
See Also:
getMarginLinePosition()

setRTextAreaUI

protected void setRTextAreaUI(RTextAreaUI ui)
Sets the UI for this RTextArea. Note that, for instances of RTextArea, setUI only updates the popup menu; this is because RTextAreas' look and feels are independent of the Java Look and Feel. This method is here so subclasses can set a UI (subclass of RTextAreaUI) if they have to.

Parameters:
ui - The new UI.
See Also:
JTextComponent.setUI(javax.swing.plaf.TextUI)

setTabsEmulated

public void setTabsEmulated(boolean areEmulated)
Changes whether or not tabs should be emulated with spaces (i.e., soft tabs). Note that this affects all tabs inserted AFTER this call, not tabs already in the document. For that, see convertTabsToSpaces() and convertSpacesToTabs().

Parameters:
areEmulated - Whether or not tabs should be emulated with spaces.
See Also:
convertSpacesToTabs(), convertTabsToSpaces(), getTabsEmulated()

setTabSize

public void setTabSize(int size)
Workaround, since in JDK1.4 it appears that setTabSize() doesn't work for a JTextArea unless you use the constructor specifying the number of rows and columns...

Sets the number of characters to expand tabs to. This will be multiplied by the maximum advance for variable width fonts. A PropertyChange event ("tabSize") is fired when the tab size changes.

Overrides:
setTabSize in class javax.swing.JTextArea
Parameters:
size - Number of characters to expand to.

updateMarginLineX

protected void updateMarginLineX()
This is here so subclasses such as RSyntaxTextArea that have multiple fonts can define exactly what it means, for example, for the margin line to be "80 characters" over.


yForLine

public int yForLine(int line)
             throws javax.swing.text.BadLocationException
Returns the y-coordinate of the specified line.

Parameters:
line - The line number.
Returns:
The y-coordinate of the top of the line, or -1 if this text area doesn't yet have a positive size or the line is hidden (i.e. from folding).
Throws:
javax.swing.text.BadLocationException - If line isn't a valid line number for this document.

yForLineContaining

public int yForLineContaining(int offs)
                       throws javax.swing.text.BadLocationException
Returns the y-coordinate of the line containing an offset.

Parameters:
offs - The offset info the document.
Returns:
The y-coordinate of the top of the offset, or -1 if this text area doesn't yet have a positive size or the line is hidden (i.e. from folding).
Throws:
javax.swing.text.BadLocationException - If offs isn't a valid offset into the document.