Class StyledText

All Implemented Interfaces:
Drawable
Direct Known Subclasses:
ContextHelpDialog.Description

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, italic, bold-italic, regular)
  • underline
  • strikeout

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.

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

IMPORTANT: This class is not intended to be subclassed.

See Also:
Restriction:
This class is not intended to be subclassed by clients.
  • Constructor Details

    • 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:
  • Method Details

    • 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.
      Parameters:
      extendedModifyListener - 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
    • addBidiSegmentListener

      public void addBidiSegmentListener(BidiSegmentListener listener)
      Adds a bidirectional segment listener.

      A BidiSegmentEvent is sent whenever a line of text is measured or rendered. You 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:
    • addCaretListener

      public void addCaretListener(CaretListener listener)
      Adds a caret listener. CaretEvent is sent when the caret offset changes.
      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:
      3.5
    • 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.
      Parameters:
      modifyListener - 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
    • addPaintObjectListener

      public void addPaintObjectListener(PaintObjectListener listener)
      Adds a paint object listener. A paint object event is sent by the widget when an object needs to be drawn.
      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:
      3.2
      See Also:
    • addSelectionListener

      public void addSelectionListener(SelectionListener listener)
      Adds a selection listener. A Selection event is sent by the widget when the user changes the selection.

      When widgetSelected is called, the event x and y fields contain the start and end caret indices of the selection[0]. The selection values returned are visual (i.e., x will always always be <= y). No event is sent when the caret is moved while the selection length is 0.

      widgetDefaultSelected is not called for StyledTexts.

      Parameters:
      listener - the listener which should be notified when the user changes the receiver's selection
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      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:
    • 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.
      Parameters:
      verifyListener - 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
    • addWordMovementListener

      public void addWordMovementListener(MovementListener movementListener)
      Adds a word movement listener. A movement event is sent when the boundary of a word is needed. For example, this occurs during word next and word previous actions.
      Parameters:
      movementListener - 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:
      3.3
      See Also:
    • 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:
    • computeSize

      public Point computeSize(int wHint, int hHint, boolean changed)
      Description copied from class: Control
      Returns the preferred size (in points) of the receiver.

      The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULT is passed for the hint.

      If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

      Overrides:
      computeSize in class Control
      Parameters:
      wHint - the width hint (can be SWT.DEFAULT)
      hHint - the height hint (can be SWT.DEFAULT)
      changed - true if the control's contents have changed, and false otherwise
      Returns:
      the preferred size of the control.
      See Also:
    • copy

      public void copy()
      Copies the selected text to the DND.CLIPBOARD clipboard.

      The text will be put on the clipboard in plain text, HTML, and RTF formats. The DND.CLIPBOARD clipboard is used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or by menu action.

      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(int clipboardType)
      Copies the selected text to the specified clipboard. The text will be put in the clipboard in plain text, HTML, and RTF formats.

      The clipboardType is one of the clipboard constants defined in class DND. The DND.CLIPBOARD clipboard is used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or by menu action. The DND.SELECTION_CLIPBOARD clipboard is used for data that is transferred by selecting text and pasting with the middle mouse button.

      Parameters:
      clipboardType - indicates the type of clipboard
      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.1
    • getAlignment

      public int getAlignment()
      Returns the alignment of the widget.
      Returns:
      the alignment
      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
      R
      Since:
      3.2
      See Also:
    • getAlwaysShowScrollBars

      public boolean getAlwaysShowScrollBars()
      Returns the Always Show Scrollbars flag. True if the scrollbars are always shown even if they are not required. False if the scrollbars are only visible when some part of the content needs to be scrolled to be seen. The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the horizontal and vertical directions.
      Returns:
      the Always Show Scrollbars flag value
      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.8
    • getMarginColor

      public Color getMarginColor()
      Returns the color of the margins.
      Returns:
      the color of the margins.
      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.5
    • cut

      public void cut()
      Moves the selected text to the clipboard. The text will be put in the clipboard in plain text, HTML, and RTF formats.
      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.

      Note: This operation is a hint and may be overridden by the platform. For example, on some versions of Windows the background of a TabFolder, is a gradient rather than a solid color.

      Overrides:
      getBackground in class Control
      Returns:
      the background color
    • getBaseline

      public int getBaseline()
      Returns the baseline, in points. Note: this API should not be used if a StyleRange attribute causes lines to have different heights (i.e. different fonts, rise, etc).
      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
      See Also:
    • getBaseline

      public int getBaseline(int offset)
      Returns the baseline at the given offset, in points.
      Parameters:
      offset - the offset
      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
      IllegalArgumentException -
      • ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())
      Since:
      3.2
    • getBidiColoring

      @Deprecated 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
    • getBlockSelection

      public boolean getBlockSelection()
      Returns whether the widget is in block selection mode.
      Returns:
      true if widget is in block selection mode, 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
      Since:
      3.5
    • getBlockSelectionBounds

      public Rectangle getBlockSelectionBounds()
      Returns the block selection bounds. The bounds is relative to the upper left corner of the document.
      Returns:
      the block selection bounds
      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.5
    • getBottomMargin

      public int getBottomMargin()
      Returns the bottom margin.
      Returns:
      the bottom margin.
      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.5
    • 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.
      Returns:
      content the user defined content implementation that is used for text storage or the default content implementation 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
    • getDragDetect

      public boolean getDragDetect()
      Description copied from class: Control
      Returns true if the receiver is detecting drag gestures, and false otherwise.
      Overrides:
      getDragDetect in class Control
      Returns:
      the receiver's drag detect state
    • 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
    • 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 SWT logical point 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
    • getIndent

      public int getIndent()
      Returns the line indentation of the widget.
      Returns:
      the line indentation
      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.2
      See Also:
    • getJustify

      public boolean getJustify()
      Returns whether the widget justifies lines.
      Returns:
      whether lines are justified
      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.2
      See Also:
    • 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
    • getLine

      public String getLine(int lineIndex)
      Returns the line at the given line index without delimiters. Index 0 is the first line of the content. When there are not any lines, getLine(0) is a valid call that answers an empty string.
      Parameters:
      lineIndex - index of the line to return.
      Returns:
      the line text without delimiters
      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 line index is outside the valid range (< 0 or >= getLineCount())
      Since:
      3.4
    • getLineAlignment

      public int getLineAlignment(int index)
      Returns the alignment of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the line alignment
      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
      Since:
      3.2
      See Also:
    • 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())
    • 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.
      Parameters:
      index - the index of the line
      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
    • getLineBullet

      public Bullet getLineBullet(int index)
      Returns the bullet of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the line bullet
      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
      Since:
      3.2
    • 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
    • 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.

      Note: this API should not be used if a StyleRange attribute causes lines to have different heights (i.e. different fonts, rise, etc).

      Returns:
      line height in points.
      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:
    • getLineHeight

      public int getLineHeight(int offset)
      Returns the line height at the given offset.
      Parameters:
      offset - the offset
      Returns:
      line height in points
      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:
      3.2
    • getLineIndent

      public int getLineIndent(int index)
      Returns the indentation of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the line indentation
      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
      Since:
      3.2
      See Also:
    • getLineVerticalIndent

      public int getLineVerticalIndent(int index)
      Returns the vertical indentation of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the line vertical indentation
      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
      Since:
      3.109
    • getLineJustify

      public boolean getLineJustify(int index)
      Returns whether the line at the given index is justified.
      Parameters:
      index - the index of the line
      Returns:
      whether the line is justified
      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
      Since:
      3.2
      See Also:
    • getLineSpacing

      public int getLineSpacing()
      Returns the line spacing of the widget.
      Returns:
      the line spacing
      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.2
    • getLinePixel

      public int getLinePixel(int lineIndex)
      Returns the top SWT logical point, relative to the client area, of a given line. Clamps out of ranges index.
      Parameters:
      lineIndex - the line index, the max value is lineCount. If lineIndex == lineCount it returns the bottom SWT logical point of the last line. It means this function can be used to retrieve the bottom SWT logical point of any line.
      Returns:
      the top SWT logical point of a given line index
      Since:
      3.2
    • getLineIndex

      public int getLineIndex(int y)
      Returns the line index for a y, relative to the client area. The line index returned is always in the range 0..lineCount - 1.
      Parameters:
      y - the y-coordinate point
      Returns:
      the line index for a given y-coordinate point
      Since:
      3.2
    • getLineTabStops

      public int[] getLineTabStops(int index)
      Returns the tab stops of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the tab stops for 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
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT when the index is invalid
      Since:
      3.6
      See Also:
    • getLineWrapIndent

      public int getLineWrapIndent(int index)
      Returns the wrap indentation of the line at the given index.
      Parameters:
      index - the index of the line
      Returns:
      the wrap indentation
      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
      Since:
      3.6
      See Also:
    • getLeftMargin

      public int getLeftMargin()
      Returns the left margin.
      Returns:
      the left margin.
      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.5
    • 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())
    • getMouseNavigatorEnabled

      public boolean getMouseNavigatorEnabled()
      Returns true if the mouse navigator is enabled. When mouse navigator is enabled, the user can navigate through the widget by pressing the middle button and moving the cursor
      Returns:
      the mouse navigator's enabled state
      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.110
      See Also:
    • 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 line index is outside the valid range (< 0 or >= getLineCount())
      Since:
      2.0
    • getOffsetAtLocation

      @Deprecated public int getOffsetAtLocation(Point point)
      Deprecated.
      Use getOffsetAtPoint(Point) instead for better performance
      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
    • getOffsetAtPoint

      public int getOffsetAtPoint(Point point)
      Returns the offset of the character at the given point 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 point. If the x coordinate of the point is beyond the center of a character the returned offset will be behind the character.

      Note: This method is functionally similar to getOffsetAtLocation(Point) except that it does not throw an exception when no character is found and thus performs faster.
      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 point relative to the first character in the document. -1 when there is no character at the specified location.
      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
      Since:
      3.107
    • getOrientation

      public int getOrientation()
      Returns the orientation of the receiver.
      Overrides:
      getOrientation in class Control
      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
    • getRanges

      public int[] getRanges()
      Returns all the ranges of text that have an associated StyleRange. 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.

      The ranges array contains start and length pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] with length ranges[n+1] uses the style at styles[n/2] returned by getStyleRanges(int, int, boolean).

      Returns:
      the ranges 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
      Since:
      3.2
      See Also:
    • getRanges

      public int[] getRanges(int start, int length)
      Returns the ranges of text that have an associated StyleRange. 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.

      The ranges array contains start and length pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] with length ranges[n+1] uses the style at styles[n/2] returned by getStyleRanges(int, int, boolean).

      Parameters:
      start - the start offset of the style ranges to return
      length - the number of style ranges to return
      Returns:
      the ranges 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
      IllegalArgumentException -
      • ERROR_INVALID_RANGE if start or length are outside the widget content
      Since:
      3.2
      See Also:
    • getRightMargin

      public int getRightMargin()
      Returns the right margin.
      Returns:
      the right margin.
      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.5
    • 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

      It is usually better to use getSelectionRanges() which better support multiple selection and carets and block selection.

      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

      public Point getSelectionRange()
      Returns the selection.

      It is usually better to use getSelectionRanges() which better support multiple selection and carets and block 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
      See Also:
    • getSelectionRanges

      public int[] getSelectionRanges()
      Returns the selected ranges of text. If block is enabled, return the ranges that are inside the block selection rectangle.

      The ranges array contains start and length pairs.

      When the receiver is not in block selection mode the return arrays contains the start and length of the regular selections.

      Returns:
      the ranges array
      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.5
      See Also:
    • 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
    • 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.

      Note: Because a StyleRange includes the start and length, the same instance cannot occur multiple times in the array of styles. If the same style attributes, such as font and color, occur in multiple StyleRanges, getStyleRanges(boolean) can be used to get the styles without the ranges.

      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
      See Also:
    • getStyleRanges

      public StyleRange[] getStyleRanges(boolean includeRanges)
      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.

      Note: When includeRanges is true, the start and length fields of each StyleRange will be valid, however the StyleRange objects may need to be cloned. When includeRanges is false, getRanges(int, int) can be used to get the associated ranges.

      Parameters:
      includeRanges - whether the start and length field of the StyleRanges should be set.
      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
      Since:
      3.2
      See Also:
    • 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.

      Note: Because the StyleRange includes the start and length, the same instance cannot occur multiple times in the array of styles. If the same style attributes, such as font and color, occur in multiple StyleRanges, getStyleRanges(int, int, boolean) can be used to get the styles without the ranges.

      Parameters:
      start - the start offset of the style ranges to return
      length - the number of style ranges to return
      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
      See Also:
    • getStyleRanges

      public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges)
      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.

      Note: When includeRanges is true, the start and length fields of each StyleRange will be valid, however the StyleRange objects may need to be cloned. When includeRanges is false, getRanges(int, int) can be used to get the associated ranges.

      Parameters:
      start - the start offset of the style ranges to return
      length - the number of style ranges to return
      includeRanges - whether the start and length field of the StyleRanges should be set.
      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.2
      See Also:
    • 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
      See Also:
    • getTabStops

      public int[] getTabStops()
      Returns the tab list of the receiver.
      Returns:
      the tab list
      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.6
    • 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:
    • getTextBounds

      public Rectangle getTextBounds(int start, int end)
      Returns the smallest bounding rectangle that includes the characters between two offsets.
      Parameters:
      start - offset of the first character included in the bounding box
      end - offset of the last character included in the bounding box
      Returns:
      bounding box of the text between start and 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
      Since:
      3.1
    • 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()
      Returns the maximum number of characters that the receiver is capable of holding.
      Returns:
      the 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
    • 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
    • getTopMargin

      public int getTopMargin()
      Returns the top margin.
      Returns:
      the top margin.
      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.5
    • getTopPixel

      public int getTopPixel()
      Gets the top SWT logical point.

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

      Returns:
      SWT logical point 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
    • getWrapIndent

      public int getWrapIndent()
      Returns the wrap indentation of the widget.
      Returns:
      the wrap indentation
      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.6
      See Also:
    • 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:
    • invokeAction

      public void invokeAction(int action)
      Executes the action.
      Parameters:
      action - one of the actions defined in ST.java
    • isTextSelected

      public boolean isTextSelected()
      Returns true if any text in the widget is selected, and false otherwise.
      Returns:
      the text selection state
      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.103
    • paste

      public void paste()
      Replaces the selection with the text on the DND.CLIPBOARD clipboard or, if there is no selection, inserts the text at the current caret offset. 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
      Returns:
      a Runnable for printing the receiver's 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_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
      Returns:
      a Runnable for printing the receiver's 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_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:
    • 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:
    • 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 which should no longer be notified
      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
    • removeCaretListener

      public void removeCaretListener(CaretListener listener)
      Removes the specified caret listener.
      Parameters:
      listener - the listener which should no longer be notified
      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:
      3.5
    • removeExtendedModifyListener

      public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
      Removes the specified extended modify listener.
      Parameters:
      extendedModifyListener - the listener which should no longer be notified
      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 which should no longer be notified
      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 which should no longer be notified
      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.
      Parameters:
      modifyListener - the listener which should no longer be notified
      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
    • removePaintObjectListener

      public void removePaintObjectListener(PaintObjectListener listener)
      Removes the specified listener.
      Parameters:
      listener - the listener which should no longer be notified
      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:
      3.2
    • removeSelectionListener

      public void removeSelectionListener(SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
      Parameters:
      listener - the listener which should no longer be notified
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      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:
    • removeVerifyListener

      public void removeVerifyListener(VerifyListener verifyListener)
      Removes the specified verify listener.
      Parameters:
      verifyListener - the listener which should no longer be notified
      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 which should no longer be notified
      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
    • removeWordMovementListener

      public void removeWordMovementListener(MovementListener listener)
      Removes the specified word movement listener.
      Parameters:
      listener - the listener which should no longer be notified
      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:
      3.3
      See Also:
    • 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.

      Note: Because a StyleRange includes the start and length, the same instance cannot occur multiple times in the array of styles. If the same style attributes, such as font and color, occur in multiple StyleRanges, setStyleRanges(int, int, int[], StyleRange[]) can be used to share styles and reduce memory usage.

      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 ranges is null
      Since:
      2.0
      See Also:
    • 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
    • scroll

      public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all)
      Description copied from class: Canvas
      Scrolls a rectangular area of the receiver by first copying the source area to the destination and then causing the area of the source which is not covered by the destination to be repainted. Children that intersect the rectangle are optionally moved during the operation. In addition, all outstanding paint events are flushed before the source area is copied to ensure that the contents of the canvas are drawn correctly.
      Overrides:
      scroll in class Canvas
      Parameters:
      destX - the x coordinate of the destination
      destY - the y coordinate of the destination
      x - the x coordinate of the source
      y - the y coordinate of the source
      width - the width of the area
      height - the height of the area
      all - trueif children should be scrolled, and false otherwise
    • 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
    • setAlignment

      public void setAlignment(int alignment)
      Sets the alignment of the widget. The argument should be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT. The alignment applies for all lines.

      Note that if SWT.MULTI is set, then SWT.WRAP must also be set in order to stabilize the right edge before setting alignment.

      Parameters:
      alignment - the new alignment
      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.2
      See Also:
    • setAlwaysShowScrollBars

      public void setAlwaysShowScrollBars(boolean show)
      Set the Always Show Scrollbars flag. True if the scrollbars are always shown even if they are not required (default value). False if the scrollbars are only visible when some part of the content needs to be scrolled to be seen. The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the horizontal and vertical directions.
      Parameters:
      show - true to show the scrollbars even when not required, false to show scrollbars only when required
      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.8
    • 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.

      Note: This operation is a hint and may be overridden by the platform.

      Overrides:
      setBackground in class Control
      Parameters:
      color - the new color (or null)
      See Also:
    • setBlockSelection

      public void setBlockSelection(boolean blockSelection)
      Sets the block selection mode.
      Parameters:
      blockSelection - true=enable block selection, false=disable block selection
      Since:
      3.5
    • setBlockSelectionBounds

      public void setBlockSelectionBounds(Rectangle rect)
      Sets the block selection bounds. The bounds is relative to the upper left corner of the document.
      Parameters:
      rect - the new bounds for the block 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_NULL_ARGUMENT when point is null
      Since:
      3.5
      See Also:
    • setBlockSelectionBounds

      public void setBlockSelectionBounds(int x, int y, int width, int height)
      Sets the block selection bounds. The bounds is relative to the upper left corner of the document.
      Parameters:
      x - the new x coordinate for the block selection
      y - the new y coordinate for the block selection
      width - the new width for the block selection
      height - the new height for the block 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
      Since:
      3.5
    • 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
    • setBidiColoring

      @Deprecated 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
    • setBottomMargin

      public void setBottomMargin(int bottomMargin)
      Sets the bottom margin.
      Parameters:
      bottomMargin - the bottom margin.
      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.5
    • 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 the offset 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.
      Parameters:
      newContent - StyledTextContent 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:
    • 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
    • setDragDetect

      public void setDragDetect(boolean dragDetect)
      Description copied from class: Control
      Sets the receiver's drag detect state. If the argument is true, the receiver will detect drag gestures, otherwise these gestures will be ignored.
      Overrides:
      setDragDetect in class Control
      Parameters:
      dragDetect - the new drag detect state
    • 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
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from class: Control
      Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.
      Overrides:
      setEnabled in class Control
      Parameters:
      enabled - the new enabled state
    • setFocus

      public boolean setFocus()
      Description copied from class: Control
      Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it. Focus reassignment will respect applicable platform constraints.
      Overrides:
      setFocus in class Composite
      Returns:
      true if the control got focus, and false if it was unable to.
      See Also:
    • setFixedLineMetrics

      public void setFixedLineMetrics(FontMetrics metrics)
      Since:
      3.125
    • 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.

      Note: This operation is a hint and may be overridden by the platform.

      Overrides:
      setForeground in class Control
      Parameters:
      color - the new color (or null)
    • 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 SWT logical point offset relative to the start of the line. Do nothing if there is no text set.

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

      Parameters:
      pixel - horizontal SWT logical point 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
    • setIndent

      public void setIndent(int indent)
      Sets the line indentation of the widget.

      It is the amount of blank space, in points, at the beginning of each line. When a line wraps in several lines only the first one is indented.

      Parameters:
      indent - the new indent
      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.2
      See Also:
    • setJustify

      public void setJustify(boolean justify)
      Sets whether the widget should justify lines.
      Parameters:
      justify - whether lines should be justified
      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.2
      See Also:
    • 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
    • setLeftMargin

      public void setLeftMargin(int leftMargin)
      Sets the left margin.
      Parameters:
      leftMargin - the left margin.
      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.5
    • setLineAlignment

      public void setLineAlignment(int startLine, int lineCount, int alignment)
      Sets the alignment of the specified lines. The argument should be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT.

      Note that if SWT.MULTI is set, then SWT.WRAP must also be set in order to stabilize the right edge before setting alignment.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.
      Parameters:
      startLine - first line the alignment is applied to, 0 based
      lineCount - number of lines the alignment applies to.
      alignment - line alignment
      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
      Since:
      3.2
      See Also:
    • 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.

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes 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
    • setLineBullet

      public void setLineBullet(int startLine, int lineCount, Bullet bullet)
      Sets the bullet of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Parameters:
      startLine - first line the bullet is applied to, 0 based
      lineCount - number of lines the bullet applies to.
      bullet - line bullet
      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
      Since:
      3.2
    • setLineIndent

      public void setLineIndent(int startLine, int lineCount, int indent)
      Sets the indent of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Parameters:
      startLine - first line the indent is applied to, 0 based
      lineCount - number of lines the indent applies to.
      indent - line indent
      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
      Since:
      3.2
      See Also:
    • setLineVerticalIndent

      public void setLineVerticalIndent(int lineIndex, int verticalLineIndent)
      Sets the vertical indent of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Setting both line spacing and vertical indent on a line would result in the spacing and indent add up for the line.

      Parameters:
      lineIndex - line index the vertical indent is applied to, 0 based
      verticalLineIndent - vertical line indent
      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 index is invalid
      Since:
      3.109
    • setLineJustify

      public void setLineJustify(int startLine, int lineCount, boolean justify)
      Sets the justify of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Parameters:
      startLine - first line the justify is applied to, 0 based
      lineCount - number of lines the justify applies to.
      justify - true if lines should be justified
      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
      Since:
      3.2
      See Also:
    • setLineSpacing

      public void setLineSpacing(int lineSpacing)
      Sets the line spacing of the widget. The line spacing applies for all lines. In the case of #setLineSpacingProvider(StyledTextLineSpacingProvider) is customized, the line spacing are applied only for the lines which are not managed by StyledTextLineSpacingProvider.
      Parameters:
      lineSpacing - the line spacing
      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.2
      See Also:
    • setLineSpacingProvider

      public void setLineSpacingProvider(StyledTextLineSpacingProvider lineSpacingProvider)
      Sets the line spacing provider of the widget. The line spacing applies for some lines with customized spacing or reset the customized spacing if the argument is null.
      Parameters:
      lineSpacingProvider - the line spacing provider (or 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
      Since:
      3.107
      See Also:
    • setLineTabStops

      public void setLineTabStops(int startLine, int lineCount, int[] tabStops)
      Sets the tab stops of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Parameters:
      startLine - first line the justify is applied to, 0 based
      lineCount - number of lines the justify applies to.
      tabStops - tab stops
      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
      Since:
      3.6
      See Also:
    • setLineWrapIndent

      public void setLineWrapIndent(int startLine, int lineCount, int wrapIndent)
      Sets the wrap indent of the specified lines.

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

      All line attributes 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 attributes 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 attributes take precedence and the attributes of the bottom line are deleted. For all other text changes line attributes will remain unchanged.

      Parameters:
      startLine - first line the wrap indent is applied to, 0 based
      lineCount - number of lines the wrap indent applies to.
      wrapIndent - line wrap indent
      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
      Since:
      3.6
      See Also:
    • setMarginColor

      public void setMarginColor(Color color)
      Sets the color of the margins.
      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:
      3.5
    • setMargins

      public void setMargins(int leftMargin, int topMargin, int rightMargin, int bottomMargin)
      Sets the margins.
      Parameters:
      leftMargin - the left margin.
      topMargin - the top margin.
      rightMargin - the right margin.
      bottomMargin - the bottom margin.
      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.5
    • setMouseNavigatorEnabled

      public void setMouseNavigatorEnabled(boolean enabled)
      Sets the enabled state of the mouse navigator. When the mouse navigator is enabled, the user can navigate through the widget by pressing the middle button and moving the cursor.
      Parameters:
      enabled - if true, the mouse navigator is enabled, if false the mouse navigator is deactivated
      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.110
    • 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.RIGHT_TO_LEFT.
      Overrides:
      setOrientation in class Control
      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
    • setRightMargin

      public void setRightMargin(int rightMargin)
      Sets the right margin.
      Parameters:
      rightMargin - the right margin.
      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.5
    • 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_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

      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_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:
    • 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.

      Note that this is a HINT. Some platforms do not allow the application to change the selection foreground color.

      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_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

      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. A negative length places the caret at the visual start of the selection.

      Parameters:
      start - offset of the first selected character
      length - number of characters to select
      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)
    • setSelectionRanges

      public void setSelectionRanges(int[] ranges)
      Sets the selected locations/ranges.

      The new selection may not be visible. Call showSelection to scroll the selection into view. A negative length places the caret at the visual start of the selection.

      Parameters:
      ranges - an array of offset/length pairs.
      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 one selection range is inside a multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
      • ERROR_INVALID_ARGUMENT when ranges are null or size isn't valid (not pair)
      Since:
      3.117
      See Also:
    • 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(int start, int length, int[] ranges, StyleRange[] styles)
      Clears the styles in the range specified by start and length and adds the new styles.

      The ranges array contains start and length pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] with length ranges[n+1] uses the style at styles[n/2]. The range fields within each StyleRange are ignored. If ranges or styles is null, the specified range is cleared.

      Note: It is expected that the same instance of a StyleRange will occur multiple times within the styles array, reducing memory usage.

      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 - the array of ranges. The ranges must not overlap and must be in order.
      styles - the array of StyleRanges. The range fields within the StyleRange are unused.
      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 an element in the styles array is null
      • ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)
      • ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)
      • ERROR_INVALID_RANGE when a range overlaps
      Since:
      3.2
    • setStyleRanges

      public void setStyleRanges(int[] ranges, StyleRange[] styles)
      Sets styles to be used for rendering the widget content.

      All styles in the widget will be replaced with the given set of ranges and styles. The ranges array contains start and length pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] with length ranges[n+1] uses the style at styles[n/2]. The range fields within each StyleRange are ignored. If either argument is null, the styles are cleared.

      Note: It is expected that the same instance of a StyleRange will occur multiple times within the styles array, reducing memory usage.

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

      Parameters:
      ranges - the array of ranges. The ranges must not overlap and must be in order.
      styles - the array of StyleRanges. The range fields within the StyleRange are unused.
      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 an element in the styles array is null
      • ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)
      • ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)
      • ERROR_INVALID_RANGE when a range overlaps
      Since:
      3.2
    • 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.

      Note: Because a StyleRange includes the start and length, the same instance cannot occur multiple times in the array of styles. If the same style attributes, such as font and color, occur in multiple StyleRanges, setStyleRanges(int[], StyleRange[]) can be used to share styles and reduce memory usage.

      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. The styles need to be in order.
      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 the list of ranges is null
      • ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())
      See Also:
    • 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
      See Also:
    • setTabStops

      public void setTabStops(int[] tabs)
      Sets the receiver's tab list. Each value in the tab list specifies the space in points from the origin of the document to the respective tab stop. The last tab stop width is repeated continuously.
      Parameters:
      tabs - the new tab list (or 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_ARGUMENT - if a tab stop is negative or less than the previous stop in the list
      Since:
      3.6
      See Also:
    • 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
    • setTextDirection

      public void setTextDirection(int textDirection)
      Sets the base text direction (a.k.a. "paragraph direction") of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.

      setOrientation would override this value with the text direction that is consistent with the new orientation.

      Warning: This API is currently only implemented on Windows. It doesn't set the base text direction on GTK and Cocoa.

      Overrides:
      setTextDirection in class Control
      Parameters:
      textDirection - the base text direction 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
      See Also:
    • setTextLimit

      public void setTextLimit(int limit)
      Sets the text limit to the specified number of characters.

      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.

      Parameters:
      topIndex - new top index. Must be between 0 and getLineCount() - fully visible lines per page. If no lines are fully visible the maximum value is getLineCount() - 1. An out of range index 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
    • setTopMargin

      public void setTopMargin(int topMargin)
      Sets the top margin.
      Parameters:
      topMargin - the top margin.
      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.5
    • setTopPixel

      public void setTopPixel(int pixel)
      Sets the top SWT logical point offset. Do nothing if there is no text set.

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

      Parameters:
      pixel - new top point 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
    • 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
    • setWrapIndent

      public void setWrapIndent(int wrapIndent)
      Sets the wrap line indentation of the widget.

      It is the amount of blank space, in points, at the beginning of each wrapped line. When a line wraps in several lines all the lines but the first one is indented by this amount.

      Parameters:
      wrapIndent - the new wrap indent
      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.6
      See Also:
    • 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