Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.swt.custom
Class StyledText

    java.lang.Object
      org.eclipse.swt.widgets.Widget
          org.eclipse.swt.widgets.Control
              org.eclipse.swt.widgets.Scrollable
                  org.eclipse.swt.widgets.Composite
                      org.eclipse.swt.widgets.Canvas
                          org.eclipse.swt.custom.StyledText

All Implemented Interfaces:
  Drawable

public class StyledText
extends Canvas

A StyledText is an editable user interface object that displays lines of text. The following style attributes can be defined for the text:

- foreground color
- background color
- font style (bold, regular)

In addition to text style attributes, the background color of a line may be specified.

There are two ways to use this widget when specifying text style information. You may use the API that is defined for StyledText or you may define your own LineStyleListener. If you define your own listener, you will be responsible for maintaining the text style information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineStyleListener:

- getStyleRangeAtOffset(int)
- getStyleRanges()
- replaceStyleRanges(int,int,StyleRange[])
- setStyleRange(StyleRange)
- setStyleRanges(StyleRange[])

There are two ways to use this widget when specifying line background colors. You may use the API that is defined for StyledText or you may define your own LineBackgroundListener. If you define your own listener, you will be responsible for maintaining the line background color information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineBackgroundListener:

- getLineBackground(int)
- setLineBackground(int,int,Color)

The content implementation for this widget may also be user-defined. To do so, you must implement the StyledTextContent interface and use the StyledText API setContent(StyledTextContent) to initialize the widget.

IMPORTANT: This class is not intended to be subclassed.

Styles:
  FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
Events:
  ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey

Field Summary

Fields inherited from class org.eclipse.swt.widgets.Control
`handle`

Constructor Summary
`StyledText(Composite parent, int style)` Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary
`void` | `addBidiSegmentListener(BidiSegmentListener listener)` Adds a bidirectional segment listener.
`void` | `addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)` Adds an extended modify listener.
`void` | `addLineBackgroundListener(LineBackgroundListener listener)` Adds a line background listener.
`void` | `addLineStyleListener(LineStyleListener listener)` Adds a line style listener.
`void` | `addModifyListener(ModifyListener modifyListener)` Adds a modify listener.
`void` | `addSelectionListener(SelectionListener listener)` Adds a selection listener.
`void` | `addVerifyKeyListener(VerifyKeyListener listener)` Adds a verify key listener.
`void` | `addVerifyListener(VerifyListener verifyListener)` Adds a verify listener.
`void` | `append(String string)` Appends a string to the text at the end of the widget.
`Point` | `computeSize(int wHint, int hHint, boolean changed)` Computes the preferred size.
`void` | `copy()` Copies the selected text to the clipboard.
`void` | `cut()` Moves the selected text to the clipboard.
`Color` | `getBackground()` Returns the receiver's background color.
`int` | `getBaseline()` Returns the baseline, in pixels.
`boolean` | `getBidiColoring()` Deprecated. use BidiSegmentListener instead.
`int` | `getCaretOffset()` Returns the caret position relative to the start of the text.
`int` | `getCharCount()` Gets the number of characters.
`StyledTextContent` | `getContent()` Returns the content implementation that is used for text storage or null if no user defined content implementation has been set.
`boolean` | `getDoubleClickEnabled()` Returns whether the widget implements double click mouse behavior.
`boolean` | `getEditable()` Returns whether the widget content can be edited.
`Color` | `getForeground()` Returns the foreground color that the receiver will use to draw.
`int` | `getHorizontalIndex()` Returns the horizontal scroll offset relative to the start of the line.
`int` | `getHorizontalPixel()` Returns the horizontal scroll offset relative to the start of the line.
`int` | `getKeyBinding(int key)` Returns the action assigned to the key.
`int` | `getLineAtOffset(int offset)` Returns the line at the specified offset in the text where 0 <= offset <= getCharCount() so that getLineAtOffset(getCharCount()) returns the line of the insert location.
`Color` | `getLineBackground(int index)` Returns the background color of the line at the given index.
`int` | `getLineCount()` Gets the number of text lines.
`String` | `getLineDelimiter()` Returns the line delimiter used for entering new lines by key down or paste operation.
`int` | `getLineHeight()` Returns the line height.
`Point` | `getLocationAtOffset(int offset)` Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text.
`int` | `getOffsetAtLine(int lineIndex)` Returns the character offset of the first character of the given line.
`int` | `getOffsetAtLocation(Point point)` Returns the offset of the character at the given location relative to the first character in the document.
`int` | `getOrientation()` Return the orientation of the receiver.
`Point` | `getSelection()` Returns the selection.
`Color` | `getSelectionBackground()` Returns the receiver's selection background color.
`int` | `getSelectionCount()` Gets the number of selected characters.
`Color` | `getSelectionForeground()` Returns the receiver's selection foreground color.
`Point` | `getSelectionRange()` Returns the selection.
`String` | `getSelectionText()` Returns the selected text.
`int` | `getStyle()` Returns the receiver's style information.
`StyleRange` | `getStyleRangeAtOffset(int offset)` Returns the style range at the given offset.
`StyleRange[]` | `getStyleRanges()` Returns the styles.
`StyleRange[]` | `getStyleRanges(int start, int length)` Returns the styles for the given text range.
`int` | `getTabs()` Returns the tab width measured in characters.
`String` | `getText()` Returns a copy of the widget content.
`String` | `getText(int start, int end)` Returns the widget content between the two offsets.
`int` | `getTextLimit()` Gets the text limit.
`String` | `getTextRange(int start, int length)` Returns the widget content starting at start for length characters.
`int` | `getTopIndex()` Gets the top index.
`int` | `getTopPixel()` Gets the top pixel.
`boolean` | `getWordWrap()` Returns whether the widget wraps lines.
`void` | `insert(String string)` Inserts a string.
`void` | `invokeAction(int action)` Executes the action.
`void` | `paste()` Replaces the selection with the clipboard text or insert the text at the current caret offset if there is no selection.
`void` | `print()` Prints the widget's text to the default printer.
`Runnable` | `print(Printer printer)` Returns a runnable that will print the widget's text to the specified printer.
`Runnable` | `print(Printer printer, StyledTextPrintOptions options)` Returns a runnable that will print the widget's text to the specified printer.
`void` | `redraw()` Causes the entire bounds of the receiver to be marked as needing to be redrawn.
`void` | `redraw(int x, int y, int width, int height, boolean all)` Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn.
`void` | `redrawRange(int start, int length, boolean clearBackground)` Redraws the specified text range.
`void` | `removeBidiSegmentListener(BidiSegmentListener listener)` Removes the specified bidirectional segment listener.
`void` | `removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)` Removes the specified extended modify listener.
`void` | `removeLineBackgroundListener(LineBackgroundListener listener)` Removes the specified line background listener.
`void` | `removeLineStyleListener(LineStyleListener listener)` Removes the specified line style listener.
`void` | `removeModifyListener(ModifyListener modifyListener)` Removes the specified modify listener.
`void` | `removeSelectionListener(SelectionListener listener)` Removes the specified selection listener.
`void` | `removeVerifyKeyListener(VerifyKeyListener listener)` Removes the specified key verify listener.
`void` | `removeVerifyListener(VerifyListener verifyListener)` Removes the specified verify listener.
`void` | `replaceStyleRanges(int start, int length, StyleRange[] ranges)` Replaces the styles in the given range with new styles.
`void` | `replaceTextRange(int start, int length, String text)` Replaces the given text range with new text.
`void` | `selectAll()` Selects all the text.
`void` | `setBackground(Color color)` Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
`void` | `setBidiColoring(boolean mode)` Deprecated. use BidiSegmentListener instead.
`void` | `setCaret(Caret caret)` Sets the receiver's caret.
`void` | `setCaretOffset(int offset)` Sets the caret offset.
`void` | `setContent(StyledTextContent newContent)` Sets the content implementation to use for text storage.
`void` | `setCursor(Cursor cursor)` Sets the receiver's cursor to the cursor specified by the argument.
`void` | `setDoubleClickEnabled(boolean enable)` Sets whether the widget implements double click mouse behavior.
`void` | `setEditable(boolean editable)` Sets whether the widget content can be edited.
`void` | `setFont(Font font)` Sets a new font to render text with.
`void` | `setForeground(Color color)` Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
`void` | `setHorizontalIndex(int offset)` Sets the horizontal scroll offset relative to the start of the line.
`void` | `setHorizontalPixel(int pixel)` Sets the horizontal pixel offset relative to the start of the line.
`void` | `setKeyBinding(int key, int action)` Maps a key to an action.
`void` | `setLineBackground(int startLine, int lineCount, Color background)` Sets the background color of the specified lines.
`void` | `setOrientation(int orientation)` Sets the orientation of the receiver, which must be one of the constants `SWT.LEFT_TO_RIGHT` or `SWT.LEFT_TO_RIGHT`.
`void` | `setSelection(int start)` Sets the selection to the given position and scrolls it into view.
`void` | `setSelection(int start, int end)` Sets the selection and scrolls it into view.
`void` | `setSelection(Point point)` Sets the selection and scrolls it into view.
`void` | `setSelectionBackground(Color color)` Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null.
`void` | `setSelectionForeground(Color color)` Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
`void` | `setSelectionRange(int start, int length)` Sets the selection.
`void` | `setStyleRange(StyleRange range)` Adds the specified style.
`void` | `setStyleRanges(StyleRange[] ranges)` Sets styles to be used for rendering the widget content.
`void` | `setTabs(int tabs)` Sets the tab width.
`void` | `setText(String text)` Sets the widget content.
`void` | `setTextLimit(int limit)` Sets the text limit.
`void` | `setTopIndex(int topIndex)` Sets the top index.
`void` | `setTopPixel(int pixel)` Sets the top pixel offset.
`void` | `setWordWrap(boolean wrap)` Sets whether the widget wraps lines.
`void` | `showSelection()` /** Scrolls the selection into view.

Methods inherited from class org.eclipse.swt.widgets.Canvas
`getCaret, scroll`

Methods inherited from class org.eclipse.swt.widgets.Composite
`checkSubclass, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList`

Methods inherited from class org.eclipse.swt.widgets.Scrollable
`computeTrim, getClientArea, getHorizontalBar, getVerticalBar`

Methods inherited from class org.eclipse.swt.widgets.Control
`addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBorderWidth, getBounds, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBounds, setBounds, setCapture, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update`

Methods inherited from class org.eclipse.swt.widgets.Widget
`addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### StyledText

    public StyledText(Composite parent,
                      int style)

  Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

  The style value is either one of the style constants defined in class `SWT` which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the `int` "|" operator) two or more of those `SWT` style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
  `parent` - a widget which will be the parent of the new instance (cannot be null)
  `style` - the style of widget to construct
Throws:
  `IllegalArgumentException` -
  - ERROR_NULL_ARGUMENT - if the parent is null
  `SWTException` -
  - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
See Also:
  `SWT.FULL_SELECTION`, `SWT.MULTI`, `SWT.READ_ONLY`, `SWT.SINGLE`, `SWT.WRAP`, `getStyle()`

Method Detail

### addExtendedModifyListener

    public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)

  Adds an extended modify listener. An ExtendedModify event is sent by the widget when the widget text has changed.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### setKeyBinding

    public void setKeyBinding(int key,
                              int action)

  Maps a key to an action. One action can be associated with N keys. However, each key can only have one action (key:action is N:1 relation).

  Parameters:
    `key` - a key code defined in SWT.java or a character. Optionally ORd with a state mask. Preferred state masks are one or more of SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform differences. However, there may be cases where using the specific state masks (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
    `action` - one of the predefined actions defined in ST.java. Use SWT.NULL to remove a key binding.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### addBidiSegmentListener

    public void addBidiSegmentListener(BidiSegmentListener listener)

  Adds a bidirectional segment listener. A BidiSegmentEvent is sent whenever a line of text is measured or rendered. The user can specify text ranges in the line that should be treated as if they had a different direction than the surrounding text. This may be used when adjacent segments of right-to-left text should not be reordered relative to each other. E.g., Multiple Java string literals in a right-to-left language should generally remain in logical order to each other, that is, the way they are stored.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null
  Since:
    2.0
  See Also:
    `BidiSegmentEvent`

### addLineBackgroundListener

    public void addLineBackgroundListener(LineBackgroundListener listener)

  Adds a line background listener. A LineGetBackground event is sent by the widget to determine the background color for a line.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### addLineStyleListener

    public void addLineStyleListener(LineStyleListener listener)

  Adds a line style listener. A LineGetStyle event is sent by the widget to determine the styles for a line.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### addModifyListener

    public void addModifyListener(ModifyListener modifyListener)

  Adds a modify listener. A Modify event is sent by the widget when the widget text has changed.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### addSelectionListener

    public void addSelectionListener(SelectionListener listener)

  Adds a selection listener. A Selection event is sent by the widget when the selection has changed.

  When `widgetSelected` is called, the event x amd y fields contain the start and end caret indices of the selection. `widgetDefaultSelected` is not called for StyledTexts.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### addVerifyKeyListener

    public void addVerifyKeyListener(VerifyKeyListener listener)

  Adds a verify key listener. A VerifyKey event is sent by the widget when a key is pressed. The widget ignores the key press if the listener sets the doit field of the event to false.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### addVerifyListener

    public void addVerifyListener(VerifyListener verifyListener)

  Adds a verify listener. A Verify event is sent by the widget when the widget text is about to change. The listener can set the event text and the doit field to change the text that is set in the widget or to force the widget to ignore the text change.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### append

    public void append(String string)

  Appends a string to the text at the end of the widget.

  Parameters:
    `string` - the string to be appended
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null
  See Also:
    `replaceTextRange(int,int,String)`

### computeSize

    public Point computeSize(int wHint,
                             int hHint,
                             boolean changed)

  Computes the preferred size.

  Overrides:
    `computeSize` in class `Composite`
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### copy

    public void copy()

  Copies the selected text to the clipboard. The text will be put in the clipboard in plain text format and RTF format.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### cut

    public void cut()

  Moves the selected text to the clipboard. The text will be put in the clipboard in plain text format and RTF format.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getBackground

    public Color getBackground()

  Description copied from class: `Control`
  Returns the receiver's background color.

  Overrides:
    `getBackground` in class `Control`
  Returns:
    the background color
  See Also:
    `Control.getBackground()`

### getBaseline

    public int getBaseline()

  Returns the baseline, in pixels.

  Returns:
    baseline the baseline
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    3.0

### getBidiColoring

    public boolean getBidiColoring()

  Deprecated. use BidiSegmentListener instead.

  Gets the BIDI coloring mode. When true the BIDI text display algorithm is applied to segments of text that are the same color.

  Returns:
    the current coloring mode
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getCaretOffset

    public int getCaretOffset()

  Returns the caret position relative to the start of the text.

  Returns:
    the caret position relative to the start of the text.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getContent

    public StyledTextContent getContent()

  Returns the content implementation that is used for text storage or null if no user defined content implementation has been set.

  Returns:
    content implementation that is used for text storage or null if no user defined content implementation has been set.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getDoubleClickEnabled

    public boolean getDoubleClickEnabled()

  Returns whether the widget implements double click mouse behavior.

  Returns:
    true if double clicking a word selects the word, false if double clicks have the same effect as regular mouse clicks
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getEditable

    public boolean getEditable()

  Returns whether the widget content can be edited.

  Returns:
    true if content can be edited, false otherwise
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getForeground

    public Color getForeground()

  Description copied from class: `Control`
  Returns the foreground color that the receiver will use to draw.

  Overrides:
    `getForeground` in class `Control`
  Returns:
    the receiver's foreground color
  See Also:
    `Control.getForeground()`

### getHorizontalIndex

    public int getHorizontalIndex()

  Returns the horizontal scroll offset relative to the start of the line.

  Returns:
    horizontal scroll offset relative to the start of the line, measured in character increments starting at 0, if > 0 the content is scrolled
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getHorizontalPixel

    public int getHorizontalPixel()

  Returns the horizontal scroll offset relative to the start of the line.

  Returns:
    the horizontal scroll offset relative to the start of the line, measured in pixel starting at 0, if > 0 the content is scrolled.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getKeyBinding

    public int getKeyBinding(int key)

  Returns the action assigned to the key. Returns SWT.NULL if there is no action associated with the key.

  Parameters:
    `key` - a key code defined in SWT.java or a character. Optionally ORd with a state mask. Preferred state masks are one or more of SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform differences. However, there may be cases where using the specific state masks (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
  Returns:
    one of the predefined actions defined in ST.java or SWT.NULL if there is no action associated with the key.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getCharCount

    public int getCharCount()

  Gets the number of characters.

  Returns:
    number of characters in the widget
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getLineBackground

    public Color getLineBackground(int index)

  Returns the background color of the line at the given index. Returns null if a LineBackgroundListener has been set or if no background color has been specified for the line. Should not be called if a LineBackgroundListener has been set since the listener maintains the line background colors.

  Returns:
    the background color of the line at the given index.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT when the index is invalid

### getLineCount

    public int getLineCount()

  Gets the number of text lines.

  Returns:
    the number of lines in the widget
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getLineAtOffset

    public int getLineAtOffset(int offset)

  Returns the line at the specified offset in the text where 0 <= offset <= getCharCount() so that getLineAtOffset(getCharCount()) returns the line of the insert location.

  Parameters:
    `offset` - offset relative to the start of the content. 0 <= offset <= getCharCount()
  Returns:
    line at the specified offset in the text
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())

### getLineDelimiter

    public String getLineDelimiter()

  Returns the line delimiter used for entering new lines by key down or paste operation.

  Returns:
    line delimiter used for entering new lines by key down or paste operation.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getLineHeight

    public int getLineHeight()

  Returns the line height.

  Returns:
    line height in pixel.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getLocationAtOffset

    public Point getLocationAtOffset(int offset)

  Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text. The point is relative to the upper left corner of the widget client area.

  Parameters:
    `offset` - offset relative to the start of the content. 0 <= offset <= getCharCount()
  Returns:
    x, y location of the upper left corner of the character bounding box at the specified offset in the text.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())

### getOffsetAtLine

    public int getOffsetAtLine(int lineIndex)

  Returns the character offset of the first character of the given line.

  Parameters:
    `lineIndex` - index of the line, 0 based relative to the first line in the content. 0 <= lineIndex < getLineCount(), except lineIndex may always be 0
  Returns:
    offset offset of the first character of the line, relative to the beginning of the document. The first character of the document is at offset 0. When there are not any lines, getOffsetAtLine(0) is a valid call that answers 0.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())
  Since:
    2.0

### getOffsetAtLocation

    public int getOffsetAtLocation(Point point)

  Returns the offset of the character at the given location relative to the first character in the document. The return value reflects the character offset that the caret will be placed at if a mouse click occurred at the specified location. If the x coordinate of the location is beyond the center of a character the returned offset will be behind the character.

  Parameters:
    `point` - the origin of character bounding box relative to the origin of the widget client area.
  Returns:
    offset of the character at the given location relative to the first character in the document.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when point is null
    - ERROR_INVALID_ARGUMENT when there is no character at the specified location

### getOrientation

    public int getOrientation()

  Return the orientation of the receiver.

  Returns:
    the orientation style
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1.2

### getSelection

    public Point getSelection()

  Returns the selection.

  Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

  Returns:
    start and end of the selection, x is the offset of the first selected character, y is the offset after the last selected character. The selection values returned are visual (i.e., x will always always be <= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right (LtoR), compare the caretOffset to the start and end of the selection (e.g., caretOffset == start of selection implies that the selection is RtoL).
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  See Also:
    `getSelectionRange()`

### getSelectionRange

    public Point getSelectionRange()

  Returns the selection.

  Returns:
    start and length of the selection, x is the offset of the first selected character, relative to the first character of the widget content. y is the length of the selection. The selection values returned are visual (i.e., length will always always be positive). To determine if a selection is right-to-left (RtoL) vs. left-to-right (LtoR), compare the caretOffset to the start and end of the selection (e.g., caretOffset == start of selection implies that the selection is RtoL).
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getSelectionBackground

    public Color getSelectionBackground()

  Returns the receiver's selection background color.

  Returns:
    the selection background color
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1

### getSelectionCount

    public int getSelectionCount()

  Gets the number of selected characters.

  Returns:
    the number of selected characters.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getSelectionForeground

    public Color getSelectionForeground()

  Returns the receiver's selection foreground color.

  Returns:
    the selection foreground color
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1

### getSelectionText

    public String getSelectionText()

  Returns the selected text.

  Returns:
    selected text, or an empty String if there is no selection.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getStyle

    public int getStyle()

  Description copied from class: `Widget`
  Returns the receiver's style information.

  Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the `SWT.H_SCROLL` and `SWT.V_SCROLL` bits set.

  Overrides:
    `getStyle` in class `Widget`
  Returns:
    the style bits

### getStyleRangeAtOffset

    public StyleRange getStyleRangeAtOffset(int offset)

  Returns the style range at the given offset. Returns null if a LineStyleListener has been set or if a style is not set for the offset. Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Parameters:
    `offset` - the offset to return the style for. 0 <= offset < getCharCount() must be true.
  Returns:
    a StyleRange with start == offset and length == 1, indicating the style at the given offset. null if a LineStyleListener has been set or if a style is not set for the given offset.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT when the offset is invalid

### getStyleRanges

    public StyleRange[] getStyleRanges()

  Returns the styles. Returns an empty array if a LineStyleListener has been set. Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Returns:
    the styles or an empty array if a LineStyleListener has been set.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getStyleRanges

    public StyleRange[] getStyleRanges(int start,
                                       int length)

  Returns the styles for the given text range. Returns an empty array if a LineStyleListener has been set. Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Returns:
    the styles or an empty array if a LineStyleListener has been set. The returned styles will reflect the given range. The first returned `StyleRange` will have a starting offset >= start and the last returned `StyleRange` will have an ending offset <= start + length - 1
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start and/or end are outside the widget content
  Since:
    3.0

### getTabs

    public int getTabs()

  Returns the tab width measured in characters.

  Returns:
    tab width measured in characters
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getText

    public String getText()

  Returns a copy of the widget content.

  Returns:
    copy of the widget content
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getText

    public String getText(int start,
                          int end)

  Returns the widget content between the two offsets.

  Parameters:
    `start` - offset of the first character in the returned String
    `end` - offset of the last character in the returned String
  Returns:
    widget content starting at start and ending at end
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start and/or end are outside the widget content
  See Also:
    `getTextRange(int,int)`

### getTextRange

    public String getTextRange(int start,
                               int length)

  Returns the widget content starting at start for length characters.

  Parameters:
    `start` - offset of the first character in the returned String
    `length` - number of characters to return
  Returns:
    widget content starting at start and extending length characters.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start and/or length are outside the widget content

### getTextLimit

    public int getTextLimit()

  Gets the text limit. The text limit specifies the amount of text that the user can type into the widget.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getTopIndex

    public int getTopIndex()

  Gets the top index. The top index is the index of the fully visible line that is currently at the top of the widget or the topmost partially visible line if no line is fully visible. The top index changes when the widget is scrolled. Indexing is zero based.

  Returns:
    the index of the top line
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getTopPixel

    public int getTopPixel()

  Gets the top pixel. The top pixel is the pixel position of the line that is currently at the top of the widget.The text widget can be scrolled by pixels by dragging the scroll thumb so that a partial line may be displayed at the top the widget. The top pixel changes when the widget is scrolled. The top pixel does not include the widget trimming.

  Returns:
    pixel position of the top line
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### getWordWrap

    public boolean getWordWrap()

  Returns whether the widget wraps lines.

  Returns:
    true if widget wraps lines, false otherwise
  Since:
    2.0

### insert

    public void insert(String string)

  Inserts a string. The old selection is replaced with the new text.

  Parameters:
    `string` - the string
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when string is null
  See Also:
    `replaceTextRange(int,int,String)`

### invokeAction

    public void invokeAction(int action)

  Executes the action.

  Parameters:
    `action` - one of the actions defined in ST.java

### paste

    public void paste()

  Replaces the selection with the clipboard text or insert the text at the current caret offset if there is no selection. If the widget has the SWT.SINGLE style and the clipboard text contains more than one line, only the first line without line delimiters is inserted in the widget.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### print

    public void print()

  Prints the widget's text to the default printer.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### print

    public Runnable print(Printer printer)

  Returns a runnable that will print the widget's text to the specified printer.

  The runnable may be run in a non-UI thread.

  Parameters:
    `printer` - the printer to print to
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when printer is null

### print

    public Runnable print(Printer printer,
                          StyledTextPrintOptions options)

  Returns a runnable that will print the widget's text to the specified printer.

  The runnable may be run in a non-UI thread.

  Parameters:
    `printer` - the printer to print to
    `options` - print options to use during printing
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when printer or options is null
  Since:
    2.1

### redraw

    public void redraw()

  Causes the entire bounds of the receiver to be marked as needing to be redrawn. The next time a paint request is processed, the control will be completely painted.

  Recalculates the content width for all lines in the bounds. When a `LineStyleListener` is used a redraw call is the only notification to the widget that styles have changed and that the content width may have changed.

  Overrides:
    `redraw` in class `Control`
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  See Also:
    `Control.update()`

### redraw

    public void redraw(int x,
                       int y,
                       int width,
                       int height,
                       boolean all)

  Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn. The next time a paint request is processed, that area of the receiver will be painted. If the `all` flag is `true`, any children of the receiver which intersect with the specified area will also paint their intersecting areas. If the `all` flag is `false`, the children will not be painted.

  Marks the content width of all lines in the specified rectangle as unknown. Recalculates the content width of all visible lines. When a `LineStyleListener` is used a redraw call is the only notification to the widget that styles have changed and that the content width may have changed.

  Overrides:
    `redraw` in class `Control`
  Parameters:
    `x` - the x coordinate of the area to draw
    `y` - the y coordinate of the area to draw
    `width` - the width of the area to draw
    `height` - the height of the area to draw
    `all` - `true` if children should redraw, and `false` otherwise
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  See Also:
    `Control.update()`

### redrawRange

    public void redrawRange(int start,
                            int length,
                            boolean clearBackground)

  Redraws the specified text range.

  Parameters:
    `start` - offset of the first character to redraw
    `length` - number of characters to redraw
    `clearBackground` - true if the background should be cleared as part of the redraw operation. If true, the entire redraw range will be cleared before anything is redrawn. If the redraw range includes the last character of a line (i.e., the entire line is redrawn) the line is cleared all the way to the right border of the widget. The redraw operation will be faster and smoother if clearBackground is set to false. Whether or not the flag can be set to false depends on the type of change that has taken place. If font styles or background colors for the redraw range have changed, clearBackground should be set to true. If only foreground colors have changed for the redraw range, clearBackground can be set to false.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start and/or end are outside the widget content

### removeBidiSegmentListener

    public void removeBidiSegmentListener(BidiSegmentListener listener)

  Removes the specified bidirectional segment listener.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null
  Since:
    2.0

### removeExtendedModifyListener

    public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)

  Removes the specified extended modify listener.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeLineBackgroundListener

    public void removeLineBackgroundListener(LineBackgroundListener listener)

  Removes the specified line background listener.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeLineStyleListener

    public void removeLineStyleListener(LineStyleListener listener)

  Removes the specified line style listener.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeModifyListener

    public void removeModifyListener(ModifyListener modifyListener)

  Removes the specified modify listener.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeSelectionListener

    public void removeSelectionListener(SelectionListener listener)

  Removes the specified selection listener.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeVerifyListener

    public void removeVerifyListener(VerifyListener verifyListener)

  Removes the specified verify listener.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### removeVerifyKeyListener

    public void removeVerifyKeyListener(VerifyKeyListener listener)

  Removes the specified key verify listener.

  Parameters:
    `listener` - the listener
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### replaceStyleRanges

    public void replaceStyleRanges(int start,
                                   int length,
                                   StyleRange[] ranges)

  Replaces the styles in the given range with new styles. This method effectively deletes the styles in the given range and then adds the the new styles.

  Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Parameters:
    `start` - offset of first character where styles will be deleted
    `length` - length of the range to delete styles in
    `ranges` - StyleRange objects containing the new style information. The ranges should not overlap and should be within the specified start and length. The style rendering is undefined if the ranges do overlap or are ill-defined. Must not be null.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())
    - ERROR_NULL_ARGUMENT when string is null
  Since:
    2.0

### replaceTextRange

    public void replaceTextRange(int start,
                                 int length,
                                 String text)

  Replaces the given text range with new text. If the widget has the SWT.SINGLE style and "text" contains more than one line, only the first line is rendered but the text is stored unchanged. A subsequent call to getText will return the same text that was set. Note that only a single line of text should be set when the SWT.SINGLE style is used.

  NOTE: During the replace operation the current selection is changed as follows:

  - selection before replaced text: selection unchanged
  - selection after replaced text: adjust the selection so that same text remains selected
  - selection intersects replaced text: selection is cleared and caret is placed after inserted text

  Parameters:
    `start` - offset of first character to replace
    `length` - number of characters to replace. Use 0 to insert text
    `text` - new text. May be empty to delete text.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())
    - ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported
    - ERROR_NULL_ARGUMENT when string is null

### selectAll

    public void selectAll()

  Selects all the text.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setWordWrap

    public void setWordWrap(boolean wrap)

  Sets whether the widget wraps lines. This overrides the creation style bit SWT.WRAP.

  Parameters:
    `wrap` - true=widget wraps lines, false=widget does not wrap lines
  Since:
    2.0

### setCaret

    public void setCaret(Caret caret)

  Sets the receiver's caret. Set the caret's height and location.

  Overrides:
    `setCaret` in class `Canvas`
  Parameters:
    `caret` - the new caret for the receiver
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setBackground

    public void setBackground(Color color)

  Description copied from class: `Control`
  Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

  Overrides:
    `setBackground` in class `Control`
  Parameters:
    `color` - the new color (or null)
  See Also:
    `Control.setBackground(org.eclipse.swt.graphics.Color)`

### setBidiColoring

    public void setBidiColoring(boolean mode)

  Deprecated. use BidiSegmentListener instead.

  Sets the BIDI coloring mode. When true the BIDI text display algorithm is applied to segments of text that are the same color.

  Parameters:
    `mode` - the new coloring mode
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setCaretOffset

    public void setCaretOffset(int offset)

  Sets the caret offset.

  Parameters:
    `offset` - caret offset, relative to the first character in the text.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)

### setContent

    public void setContent(StyledTextContent newContent)

  Sets the content implementation to use for text storage.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null

### setCursor

    public void setCursor(Cursor cursor)

  Sets the receiver's cursor to the cursor specified by the argument. Overridden to handle the null case since the StyledText widget uses an ibeam as its default cursor.

  Overrides:
    `setCursor` in class `Control`
  Parameters:
    `cursor` - the new cursor (or null)
  See Also:
    `Control.setCursor(org.eclipse.swt.graphics.Cursor)`

### setDoubleClickEnabled

    public void setDoubleClickEnabled(boolean enable)

  Sets whether the widget implements double click mouse behavior.

  Parameters:
    `enable` - if true double clicking a word selects the word, if false double clicks have the same effect as regular mouse clicks.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setEditable

    public void setEditable(boolean editable)

  Sets whether the widget content can be edited.

  Parameters:
    `editable` - if true content can be edited, if false content can not be edited
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setFont

    public void setFont(Font font)

  Sets a new font to render text with.

  NOTE: Italic fonts are not supported unless they have no overhang and the same baseline as regular fonts.

  Overrides:
    `setFont` in class `Canvas`
  Parameters:
    `font` - new font
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setForeground

    public void setForeground(Color color)

  Description copied from class: `Control`
  Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

  Overrides:
    `setForeground` in class `Control`
  Parameters:
    `color` - the new color (or null)
  See Also:
    `Control.setForeground(org.eclipse.swt.graphics.Color)`

### setHorizontalIndex

    public void setHorizontalIndex(int offset)

  Sets the horizontal scroll offset relative to the start of the line. Do nothing if there is no text set.

  NOTE: The horizontal index is reset to 0 when new text is set in the widget.

  Parameters:
    `offset` - horizontal scroll offset relative to the start of the line, measured in character increments starting at 0, if equal to 0 the content is not scrolled, if > 0 = the content is scrolled.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setHorizontalPixel

    public void setHorizontalPixel(int pixel)

  Sets the horizontal pixel offset relative to the start of the line. Do nothing if there is no text set.

  NOTE: The horizontal pixel offset is reset to 0 when new text is set in the widget.

  Parameters:
    `pixel` - horizontal pixel offset relative to the start of the line.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.0

### setLineBackground

    public void setLineBackground(int startLine,
                                  int lineCount,
                                  Color background)

  Sets the background color of the specified lines. The background color is drawn for the width of the widget. All line background colors are discarded when setText is called. The text background color if defined in a StyleRange overlays the line background color. Should not be called if a LineBackgroundListener has been set since the listener maintains the line backgrounds.

  Line background colors are maintained relative to the line text, not the line index that is specified in this method call. During text changes, when entire lines are inserted or removed, the line background colors that are associated with the lines after the change will "move" with their respective text. An entire line is defined as extending from the first character on a line to the last and including the line delimiter.

  When two lines are joined by deleting a line delimiter, the top line background takes precedence and the color of the bottom line is deleted. For all other text changes line background colors will remain unchanged.

  Parameters:
    `startLine` - first line the color is applied to, 0 based
    `lineCount` - number of lines the color applies to.
    `background` - line background color
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT when the specified line range is invalid

### setOrientation

    public void setOrientation(int orientation)

  Sets the orientation of the receiver, which must be one of the constants `SWT.LEFT_TO_RIGHT` or `SWT.LEFT_TO_RIGHT`.

  Parameters:
    `orientation` - new orientation style
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1.2

### setSelection

    public void setSelection(int start)

  Sets the selection to the given position and scrolls it into view. Equivalent to setSelection(start,start).

  Parameters:
    `start` - new caret position
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start is outside the widget content
    - ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
  See Also:
    `setSelection(int,int)`

### setSelection

    public void setSelection(Point point)

  Sets the selection and scrolls it into view.

  Indexing is zero based. Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

  Parameters:
    `point` - x=selection start offset, y=selection end offset The caret will be placed at the selection start when x > y.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when point is null
    - ERROR_INVALID_RANGE when start or end is outside the widget content
    - ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
  See Also:
    `setSelection(int,int)`

### setSelectionBackground

    public void setSelectionBackground(Color color)

  Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null.

  Parameters:
    `color` - the new color (or null)
  Throws:
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT - if the argument has been disposed
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1

### setSelectionForeground

    public void setSelectionForeground(Color color)

  Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

  Parameters:
    `color` - the new color (or null)
  Throws:
    `IllegalArgumentException` -
    - ERROR_INVALID_ARGUMENT - if the argument has been disposed
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.1

### setSelection

    public void setSelection(int start,
                             int end)

  Sets the selection and scrolls it into view.

  Indexing is zero based. Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

  Parameters:
    `start` - selection start offset. The caret will be placed at the selection start when start > end.
    `end` - selection end offset
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when start or end is outside the widget content
    - ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
  See Also:
    `setSelectionRange(int,int)`

### setSelectionRange

    public void setSelectionRange(int start,
                                  int length)

  Sets the selection. The new selection may not be visible. Call showSelection to scroll the selection into view.

  Parameters:
    `start` - offset of the first selected character, start >= 0 must be true.
    `length` - number of characters to select, 0 <= start + length <= getCharCount() must be true. A negative length places the caret at the visual start of the selection.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when the range specified by start and length is outside the widget content
    - ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)

### setStyleRange

    public void setStyleRange(StyleRange range)

  Adds the specified style. The new style overwrites existing styles for the specified range. Existing style ranges are adjusted if they partially overlap with the new style, To clear an individual style, call setStyleRange with a StyleRange that has null attributes.

  Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Parameters:
    `range` - StyleRange object containing the style information. Overwrites the old style in the given range. May be null to delete all styles.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_INVALID_RANGE when the style range is outside the valid range (> getCharCount())

### setStyleRanges

    public void setStyleRanges(StyleRange[] ranges)

  Sets styles to be used for rendering the widget content. All styles in the widget will be replaced with the given set of styles.

  Should not be called if a LineStyleListener has been set since the listener maintains the styles.

  Parameters:
    `ranges` - StyleRange objects containing the style information. The ranges should not overlap. The style rendering is undefined if the ranges do overlap. Must not be null.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when listener is null
    - ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())

### setTabs

    public void setTabs(int tabs)

  Sets the tab width.

  Parameters:
    `tabs` - tab width measured in characters.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setText

    public void setText(String text)

  Sets the widget content. If the widget has the SWT.SINGLE style and "text" contains more than one line, only the first line is rendered but the text is stored unchanged. A subsequent call to getText will return the same text that was set.

  Note: Only a single line of text should be set when the SWT.SINGLE style is used.

  Parameters:
    `text` - new widget content. Replaces existing content. Line styles that were set using StyledText API are discarded. The current selection is also discarded.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT when string is null

### setTextLimit

    public void setTextLimit(int limit)

  Sets the text limit.

  The text limit specifies the amount of text that the user can type into the widget.

  Parameters:
    `limit` - the new text limit.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    `IllegalArgumentException` -
    - ERROR_CANNOT_BE_ZERO when limit is 0

### setTopIndex

    public void setTopIndex(int topIndex)

  Sets the top index. Do nothing if there is no text set.

  The top index is the index of the line that is currently at the top of the widget. The top index changes when the widget is scrolled. Indexing starts from zero. Note: The top index is reset to 0 when new text is set in the widget.

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

### setTopPixel

    public void setTopPixel(int pixel)

  Sets the top pixel offset. Do nothing if there is no text set.

  The top pixel offset is the vertical pixel offset of the widget. The widget is scrolled so that the given pixel position is at the top. The top index is adjusted to the corresponding top line. Note: The top pixel is reset to 0 when new text is set in the widget.

  Parameters:
    `pixel` - new top pixel offset. Must be between 0 and (getLineCount() - visible lines per page) / getLineHeight()). An out of range offset will be adjusted accordingly.
  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  Since:
    2.0

### showSelection

    public void showSelection()

  /** Scrolls the selection into view. The end of the selection will be scrolled into view. Note that if a right-to-left selection exists, the end of the selection is the visual beginning of the selection (i.e., where the caret is located).

  Throws:
    `SWTException` -
    - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.