Class PasswordRevealer
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class PasswordRevealer
extends org.eclipse.swt.widgets.Composite
- Styles:
- CENTER, ICON_CANCEL, ICON_SEARCH, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP, PUSH
- Events:
- DefaultSelection, Modify, Verify, OrientationChange
Note: Only one of the styles MULTI and SINGLE may be specified, and only one of the styles LEFT, CENTER, and RIGHT may be specified.
Note: The styles ICON_CANCEL and ICON_SEARCH are hints used in combination with SEARCH. When the platform supports the hint, the text control shows these icons. When an icon is selected, a default selection event is sent with the detail field set to one of ICON_CANCEL or ICON_SEARCH. Normally, application code does not need to check the detail. In the case of ICON_CANCEL, the text is cleared before the default selection event is sent causing the application to search for an empty string.
IMPORTANT: This class is not intended to be subclassed.
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.swt.widgets.Text
passwordField
-
Constructor Summary
Constructors Constructor Description PasswordRevealer(org.eclipse.swt.widgets.Composite parent, int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. -
Method Summary
Modifier and Type Method Description void
addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)
Adds the listener to the collection of listeners who will be notified when a drag gesture occurs, by sending it one of the messages defined in theDragDetectListener
interface.void
addFocusListener(org.eclipse.swt.events.FocusListener listener)
Adds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in theFocusListener
interface.void
addGestureListener(org.eclipse.swt.events.GestureListener listener)
Adds the listener to the collection of listeners who will be notified when gesture events are generated for the control, by sending it one of the messages defined in theGestureListener
interface.void
addHelpListener(org.eclipse.swt.events.HelpListener listener)
Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListener
interface.void
addKeyListener(org.eclipse.swt.events.KeyListener listener)
Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in theKeyListener
interface.void
addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)
Adds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListener
interface.void
addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in theModifyListener
interface.void
addMouseListener(org.eclipse.swt.events.MouseListener listener)
Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in theMouseListener
interface.void
addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)
Adds the listener to the collection of listeners who will be notified when the mouse moves, by sending it one of the messages defined in theMouseMoveListener
interface.void
addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)
Adds the listener to the collection of listeners who will be notified when the mouse passes or hovers over controls, by sending it one of the messages defined in theMouseTrackListener
interface.void
addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
Adds the listener to the collection of listeners who will be notified when the mouse wheel is scrolled, by sending it one of the messages defined in theMouseWheelListener
interface.void
addSegmentListener(org.eclipse.swt.events.SegmentListener listener)
Adds a segment listener.void
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.void
addTouchListener(org.eclipse.swt.events.TouchListener listener)
Adds the listener to the collection of listeners who will be notified when touch events occur, by sending it one of the messages defined in theTouchListener
interface.void
addVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by sending it one of the messages defined in theVerifyListener
interface.void
append(java.lang.String string)
Appends a string.void
clearSelection()
Clears the selection.void
copy()
Copies the selected text.void
cut()
Cuts the selected text.boolean
forceFocus()
Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.int
getCaretLineNumber()
Returns the line number of the caret.org.eclipse.swt.graphics.Point
getCaretLocation()
Returns a point describing the location of the caret relative to the receiver.int
getCaretPosition()
Returns the character position of the caret.int
getCharCount()
Returns the number of characters.org.eclipse.swt.graphics.Image
getClickImage()
Returns the image displayed when the "reveal button" is clicked.boolean
getDoubleClickEnabled()
Returns the double click enabled flag.char
getEchoChar()
Returns the echo character.boolean
getEditable()
Returns the editable state.org.eclipse.swt.graphics.Image
getImage()
Returns the image used when the user wants to reveal the password of lines.int
getLineCount()
Returns the number of lines.java.lang.String
getLineDelimiter()
Returns the line delimiter.int
getLineHeight()
Returns the height of a line.java.lang.String
getMessage()
Returns the widget message.org.eclipse.swt.graphics.Point
getSelection()
Returns aPoint
whose x coordinate is the character position representing the start of the selected text, and whose y coordinate is the character position representing the end of the selection.int
getSelectionCount()
Returns the number of selected characters.java.lang.String
getSelectionText()
Gets the selected text, or an empty string if there is no current selection.int
getTabs()
Returns the number of tabs.java.lang.String
getText()
Returns the widget text.java.lang.String
getText(int start, int end)
Returns a range of text.char[]
getTextChars()
Returns the widget's text as a character array.int
getTextLimit()
Returns the maximum number of characters that the receiver is capable of holding.int
getTopIndex()
Returns the zero-relative index of the line which is currently at the top of the receiver.int
getTopPixel()
Returns the zero-relative index of the line which is currently at the top of the receiver.(package private) void
hidePassword()
void
insert(java.lang.String string)
Inserts a string.boolean
isFocusControl()
Returnstrue
if the receiver has the user-interface focus, andfalse
otherwise.boolean
isPushMode()
Returnstrue
if the eye button is a "push" button, andfalse
otherwise.void
paste()
Pastes text from clipboard.void
removeFocusListener(org.eclipse.swt.events.FocusListener listener)
Removes the listener from the collection of listeners who will be notified when the control gains or loses focus.void
removeGestureListener(org.eclipse.swt.events.GestureListener listener)
Removes the listener from the collection of listeners who will be notified when gesture events are generated for the control.void
removeHelpListener(org.eclipse.swt.events.HelpListener listener)
Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.void
removeKeyListener(org.eclipse.swt.events.KeyListener listener)
Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.void
removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)
Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.void
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.void
removeMouseListener(org.eclipse.swt.events.MouseListener listener)
Removes the listener from the collection of listeners who will be notified when mouse buttons are pressed and released.void
removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)
Removes the listener from the collection of listeners who will be notified when the mouse moves.void
removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)
Removes the listener from the collection of listeners who will be notified when the mouse passes or hovers over controls.void
removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
Removes the listener from the collection of listeners who will be notified when the mouse wheel is scrolled.void
removeSegmentListener(org.eclipse.swt.events.SegmentListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.void
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected by the user.void
removeTouchListener(org.eclipse.swt.events.TouchListener listener)
Removes the listener from the collection of listeners who will be notified when touch events occur.void
removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Removes the listener from the collection of listeners who will be notified when the control is verified.(package private) void
revealPassword()
void
selectAll()
Selects all the text in the receiver.void
setBackground(org.eclipse.swt.graphics.Color color)
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.void
setCapture(boolean capture)
If the argument istrue
, causes the receiver to have all mouse events delivered to it until the method is called withfalse
as the argument.void
setClickImage(org.eclipse.swt.graphics.Image image)
Set the image displayed when the "reveal button" is clicked.void
setCursor(org.eclipse.swt.graphics.Cursor cursor)
Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.void
setDoubleClickEnabled(boolean doubleClick)
Sets the double click enabled flag.void
setDragDetect(boolean dragDetect)
Sets the receiver's drag detect state.void
setEchoChar(char echo)
Sets the echo character.void
setEditable(boolean editable)
Sets the editable state.boolean
setFocus()
Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it.void
setFont(org.eclipse.swt.graphics.Font font)
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.void
setForeground(org.eclipse.swt.graphics.Color color)
Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.void
setImage(org.eclipse.swt.graphics.Image image)
Sets the image on which the user should click if he wants to reveal the password.void
setMenu(org.eclipse.swt.widgets.Menu menu)
Sets the receiver's pop up menu to the argument.void
setMessage(java.lang.String message)
Sets the widget message.void
setOrientation(int orientation)
Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
.void
setPushMode(boolean pushMode)
Sets the eye's button behaviour.void
setSelection(int start)
Sets the selection.void
setSelection(int start, int end)
Sets the selection to the range specified by the given start and end indices.void
setSelection(org.eclipse.swt.graphics.Point selection)
Sets the selection to the range specified by the given point, where the x coordinate represents the start index and the y coordinate represents the end index.void
setTabs(int tabs)
Sets the number of tabs.void
setText(java.lang.String string)
Sets the contents of the receiver to the given string.void
setTextChars(char[] text)
Sets the contents of the receiver to the characters in the array.void
setTextLimit(int limit)
Sets the maximum number of characters that the receiver is capable of holding to be the argument.void
setToolTipText(java.lang.String string)
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.void
setTopIndex(int index)
Sets the zero-relative index of the line which is currently at the top of the receiver.void
setTouchEnabled(boolean enabled)
Sets whether this control should send touch events (by default controls do not).void
showSelection()
Shows the selection.boolean
traverse(int traversal)
Based on the argument, perform one of the expected platform traversal action.boolean
traverse(int traversal, org.eclipse.swt.events.KeyEvent event)
Performs a platform traversal action corresponding to aKeyDown
event.boolean
traverse(int traversal, org.eclipse.swt.widgets.Event event)
Performs a platform traversal action corresponding to aKeyDown
event.Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addPaintListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removePaintListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setEnabled, setLayoutData, setLocation, setLocation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setVisible, toControl, toControl, toDisplay, toDisplay, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
passwordField
protected org.eclipse.swt.widgets.Text passwordField
-
-
Constructor Details
-
PasswordRevealer
public PasswordRevealer(org.eclipse.swt.widgets.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 theint
"|" operator) two or more of thoseSWT
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 composite control which will be the parent of the new instance (cannot be null)style
- the style of control to construct- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
Widget.getStyle()
-
-
Method Details
-
revealPassword
void revealPassword() -
hidePassword
void hidePassword() -
addModifyListener
public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in theModifyListener
interface.- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
ModifyListener
,removeModifyListener(org.eclipse.swt.events.ModifyListener)
-
addSegmentListener
public void addSegmentListener(org.eclipse.swt.events.SegmentListener listener)Adds a segment listener.A
SegmentEvent
is sent whenever text content is being modified or a segment listener is added or removed. You can customize the appearance of text by indicating certain characters to be inserted at certain text offsets. This may be used for bidi purposes, e.g. 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.Warning: This API is currently only implemented on Windows and GTK.
SegmentEvent
s won't be sent on Cocoa.- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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
- See Also:
SegmentEvent
,SegmentListener
,removeSegmentListener(org.eclipse.swt.events.SegmentListener)
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.widgetSelected
is not called for texts.widgetDefaultSelected
is typically called when ENTER is pressed in a single-line text, or when ENTER is pressed in a search text. If the receiver has theSWT.SEARCH | SWT.ICON_CANCEL
style and the user cancels the search, the event object detail field contains the valueSWT.ICON_CANCEL
. Likewise, if the receiver has theSWT.ICON_SEARCH
style and the icon search is selected, the event object detail field contains the valueSWT.ICON_SEARCH
.- Parameters:
listener
- the listener which should be notified when the control is selected by the user- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
SelectionListener
,removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,SelectionEvent
-
addVerifyListener
public void addVerifyListener(org.eclipse.swt.events.VerifyListener listener)Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by sending it one of the messages defined in theVerifyListener
interface.- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
VerifyListener
,removeVerifyListener(org.eclipse.swt.events.VerifyListener)
-
append
public void append(java.lang.String string)Appends a string.The new text is appended to the text at the end of the widget.
- Parameters:
string
- the string to be appended- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the string is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
clearSelection
public void clearSelection()Clears the selection.- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
copy
public void copy()Copies the selected text.The current selection is copied to the clipboard.
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
cut
public void cut()Cuts the selected text.The current selection is first copied to the clipboard and then deleted from the widget.
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getCaretLineNumber
public int getCaretLineNumber()Returns the line number of the caret.The line number of the caret is returned.
- Returns:
- the line number
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getCaretLocation
public org.eclipse.swt.graphics.Point getCaretLocation()Returns a point describing the location of the caret relative to the receiver.- Returns:
- a point, the location of the caret
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getCaretPosition
public int getCaretPosition()Returns the character position of the caret.Indexing is zero based.
- Returns:
- the position of the caret
- Throws:
org.eclipse.swt.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()Returns the number of characters.- Returns:
- number of characters in the widget
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getClickImage
public org.eclipse.swt.graphics.Image getClickImage()Returns the image displayed when the "reveal button" is clicked.- Returns:
- the image. If
null
it means that the default button is used - Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getDoubleClickEnabled
public boolean getDoubleClickEnabled()Returns the double click enabled flag.The double click flag enables or disables the default action of the text widget when the user double clicks.
- Returns:
- whether or not double click is enabled
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getEchoChar
public char getEchoChar()Returns the echo character.The echo character is the character that is displayed when the user enters text or the text is changed by the programmer.
- Returns:
- the echo character
- Throws:
org.eclipse.swt.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:
setEchoChar(char)
-
getEditable
public boolean getEditable()Returns the editable state.- Returns:
- whether or not the receiver is editable
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getImage
public org.eclipse.swt.graphics.Image getImage()Returns the image used when the user wants to reveal the password of lines.- Returns:
- the image.
null
means that the icon is the default one - Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getLineCount
public int getLineCount()Returns the number of lines.- Returns:
- the number of lines in the widget
- Throws:
org.eclipse.swt.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 java.lang.String getLineDelimiter()Returns the line delimiter.- Returns:
- a string that is the line delimiter
- Throws:
org.eclipse.swt.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:
#DELIMITER
-
getLineHeight
public int getLineHeight()Returns the height of a line.- Returns:
- the height of a row of text
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getMessage
public java.lang.String getMessage()Returns the widget message. The message text is displayed as a hint for the user, indicating the purpose of the field.Typically this is used in conjunction with
SWT.SEARCH
.- Returns:
- the widget message
- Throws:
org.eclipse.swt.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.3
-
getSelection
public org.eclipse.swt.graphics.Point getSelection()Returns aPoint
whose x coordinate is the character position representing the start of the selected text, and whose y coordinate is the character position representing the end of the selection. An "empty" selection is indicated by the x and y coordinates having the same value.Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
- Returns:
- a point representing the selection start and end
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelectionCount
public int getSelectionCount()Returns the number of selected characters.- Returns:
- the number of selected characters.
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelectionText
public java.lang.String getSelectionText()Gets the selected text, or an empty string if there is no current selection.- Returns:
- the selected text
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTabs
public int getTabs()Returns the number of tabs.Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces.
- Returns:
- the number of tab characters
- Throws:
org.eclipse.swt.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 java.lang.String getText()Returns the widget text.The text for a text widget is the characters in the widget, or an empty string if this has never been set.
- Returns:
- the widget text
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTextChars
public char[] getTextChars()Returns the widget's text as a character array.The text for a text widget is the characters in the widget, or a zero-length array if this has never been set.
Note: Use this API to prevent the text from being written into a String object whose lifecycle is outside of your control. This can help protect the text, for example, when the widget is used as a password field. However, the text can't be protected if an
SWT.Segments
orSWT.Verify
listener has been added to the widget.- Returns:
- a character array that contains the widget's text
- Throws:
org.eclipse.swt.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.7
- See Also:
setTextChars(char[])
-
getText
public java.lang.String getText(int start, int end)Returns a range of text. Returns an empty string if the start of the range is greater than the end.Indexing is zero based. The range of a selection is from 0..N-1 where N is the number of characters in the widget.
- Parameters:
start
- the start of the rangeend
- the end of the range- Returns:
- the range of text
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTextLimit
public int getTextLimit()Returns the maximum number of characters that the receiver is capable of holding.If this has not been changed by
setTextLimit()
, it will be the constantText.LIMIT
.- Returns:
- the text limit
- Throws:
org.eclipse.swt.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:
#LIMIT
-
getTopIndex
public int getTopIndex()Returns the zero-relative index of the line which is currently at the top of the receiver.This index can change when lines are scrolled or new lines are added or removed.
- Returns:
- the index of the top line
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTopPixel
public int getTopPixel()Returns the zero-relative index of the line which is currently at the top of the receiver.This index can change when lines are scrolled or new lines are added or removed.
- Returns:
- the index of the top line
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
insert
public void insert(java.lang.String string)Inserts a string.The old selection is replaced with the new text.
- Parameters:
string
- the string- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the string is
null
- ERROR_NULL_ARGUMENT - if the string is
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
paste
public void paste()Pastes text from clipboard.The selected text is deleted from the widget and new text inserted from the clipboard.
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
removeModifyListener
public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
ModifyListener
,addModifyListener(org.eclipse.swt.events.ModifyListener)
-
removeSegmentListener
public void removeSegmentListener(org.eclipse.swt.events.SegmentListener listener)Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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
- See Also:
SegmentEvent
,SegmentListener
,addSegmentListener(org.eclipse.swt.events.SegmentListener)
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the control is selected by the user.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
SelectionListener
,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
removeVerifyListener
public void removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)Removes the listener from the collection of listeners who will be notified when the control is verified.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
VerifyListener
,addVerifyListener(org.eclipse.swt.events.VerifyListener)
-
selectAll
public void selectAll()Selects all the text in the receiver.- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setDoubleClickEnabled
public void setDoubleClickEnabled(boolean doubleClick)Sets the double click enabled flag.The double click flag enables or disables the default action of the text widget when the user double clicks.
Note: This operation is a hint and is not supported on platforms that do not have this concept.
- Parameters:
doubleClick
- the new double click flag- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setEchoChar
public void setEchoChar(char echo)Sets the echo character.The echo character is the character that is displayed when the user enters text or the text is changed by the programmer. Setting the echo character to '\0' clears the echo character and redraws the original text. If for any reason the echo character is invalid, or if the platform does not allow modification of the echo character, the default echo character for the platform is used.
- Parameters:
echo
- the new echo character- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setEditable
public void setEditable(boolean editable)Sets the editable state.- Parameters:
editable
- the new editable state- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setFont
public void setFont(org.eclipse.swt.graphics.Font font)Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.- Overrides:
setFont
in classorg.eclipse.swt.widgets.Control
- Parameters:
font
- the new font (or null)- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setImage
public void setImage(org.eclipse.swt.graphics.Image image)Sets the image on which the user should click if he wants to reveal the password.- Parameters:
image
- the new image. Ifnull
, the default "eye" icon will be displayed- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setMessage
public void setMessage(java.lang.String message)Sets the widget message. The message text is displayed as a hint for the user, indicating the purpose of the field.Typically this is used in conjunction with
SWT.SEARCH
.- Parameters:
message
- the new message- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the message is null
org.eclipse.swt.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.3
-
setOrientation
public void setOrientation(int orientation)Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
.Note: This operation is a hint and is not supported on platforms that do not have this concept.
- Overrides:
setOrientation
in classorg.eclipse.swt.widgets.Control
- Parameters:
orientation
- new orientation style- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setPushMode
public void setPushMode(boolean pushMode)Sets the eye's button behaviour.- Parameters:
pushMode
- new push mode- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(int start)Sets the selection.Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the regular array indexing rules.
- Parameters:
start
- new caret position- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(int start, int end)Sets the selection to the range specified by the given start and end indices.Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the usual array indexing rules.
- Parameters:
start
- the start of the rangeend
- the end of the range- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(org.eclipse.swt.graphics.Point selection)Sets the selection to the range specified by the given point, where the x coordinate represents the start index and the y coordinate represents the end index.Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the usual array indexing rules.
- Parameters:
selection
- the point- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the point is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTabs
public void setTabs(int tabs)Sets the number of tabs.Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces.
- Parameters:
tabs
- the number of tabs
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
-
setText
public void setText(java.lang.String string)Sets the contents of the receiver to the given string. If the receiver has style SINGLE and the argument contains multiple lines of text, the result of this operation is undefined and may vary from platform to platform.Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.
- Parameters:
string
- the new text- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the string is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTextChars
public void setTextChars(char[] text)Sets the contents of the receiver to the characters in the array. If the receiver has styleSWT.SINGLE
and the argument contains multiple lines of text then the result of this operation is undefined and may vary between platforms.Note: Use this API to prevent the text from being written into a String object whose lifecycle is outside of your control. This can help protect the text, for example, when the widget is used as a password field. However, the text can't be protected if an
SWT.Segments
orSWT.Verify
listener has been added to the widget.- Parameters:
text
- a character array that contains the new text- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the array is null
org.eclipse.swt.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.7
- See Also:
getTextChars()
-
setTextLimit
public void setTextLimit(int limit)Sets the maximum number of characters that the receiver is capable of holding to be the argument.Instead of trying to set the text limit to zero, consider creating a read-only text widget.
To reset this value to the default, use
setTextLimit(Text.LIMIT)
. Specifying a limit value larger thanText.LIMIT
sets the receiver's limit toText.LIMIT
.- Parameters:
limit
- new text limit- Throws:
java.lang.IllegalArgumentException
-- ERROR_CANNOT_BE_ZERO - if the limit is zero
org.eclipse.swt.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:
#LIMIT
-
setTopIndex
public void setTopIndex(int index)Sets the zero-relative index of the line which is currently at the top of the receiver. This index can change when lines are scrolled or new lines are added and removed.- Parameters:
index
- the index of the top item- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
showSelection
public void showSelection()Shows the selection.If the selection is already showing in the receiver, this method simply returns. Otherwise, lines are scrolled until the selection is visible.
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
addDragDetectListener
public void addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)Adds the listener to the collection of listeners who will be notified when a drag gesture occurs, by sending it one of the messages defined in theDragDetectListener
interface.- Overrides:
addDragDetectListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.3
- See Also:
DragDetectListener
,Control.removeDragDetectListener(org.eclipse.swt.events.DragDetectListener)
-
addFocusListener
public void addFocusListener(org.eclipse.swt.events.FocusListener listener)Adds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in theFocusListener
interface.- Overrides:
addFocusListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
FocusListener
,removeFocusListener(org.eclipse.swt.events.FocusListener)
-
addGestureListener
public void addGestureListener(org.eclipse.swt.events.GestureListener listener)Adds the listener to the collection of listeners who will be notified when gesture events are generated for the control, by sending it one of the messages defined in theGestureListener
interface.NOTE: If
setTouchEnabled(true)
has previously been invoked on the receiver thensetTouchEnabled(false)
must be invoked on it to specify that gesture events should be sent instead of touch events.Warning: This API is currently only implemented on Windows and Cocoa. SWT doesn't send Gesture or Touch events on GTK.
- Overrides:
addGestureListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.7
- See Also:
GestureListener
,removeGestureListener(org.eclipse.swt.events.GestureListener)
,setTouchEnabled(boolean)
-
addHelpListener
public void addHelpListener(org.eclipse.swt.events.HelpListener listener)Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListener
interface.- Overrides:
addHelpListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
HelpListener
,removeHelpListener(org.eclipse.swt.events.HelpListener)
-
addKeyListener
public void addKeyListener(org.eclipse.swt.events.KeyListener listener)Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in theKeyListener
interface.When a key listener is added to a control, the control will take part in widget traversal. By default, all traversal keys (such as the tab key and so on) are delivered to the control. In order for a control to take part in traversal, it should listen for traversal events. Otherwise, the user can traverse into a control but not out. Note that native controls such as table and tree implement key traversal in the operating system. It is not necessary to add traversal listeners for these controls, unless you want to override the default traversal.
- Overrides:
addKeyListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
KeyListener
,removeKeyListener(org.eclipse.swt.events.KeyListener)
-
addMenuDetectListener
public void addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)Adds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListener
interface.- Overrides:
addMenuDetectListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.3
- See Also:
MenuDetectListener
,removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener)
-
addMouseListener
public void addMouseListener(org.eclipse.swt.events.MouseListener listener)Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in theMouseListener
interface.- Overrides:
addMouseListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseListener
,removeMouseListener(org.eclipse.swt.events.MouseListener)
-
addMouseTrackListener
public void addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)Adds the listener to the collection of listeners who will be notified when the mouse passes or hovers over controls, by sending it one of the messages defined in theMouseTrackListener
interface.- Overrides:
addMouseTrackListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseTrackListener
,removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener)
-
addMouseMoveListener
public void addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)Adds the listener to the collection of listeners who will be notified when the mouse moves, by sending it one of the messages defined in theMouseMoveListener
interface.- Overrides:
addMouseMoveListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseMoveListener
,removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener)
-
addMouseWheelListener
public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)Adds the listener to the collection of listeners who will be notified when the mouse wheel is scrolled, by sending it one of the messages defined in theMouseWheelListener
interface.- Overrides:
addMouseWheelListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.3
- See Also:
MouseWheelListener
,removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener)
-
addTouchListener
public void addTouchListener(org.eclipse.swt.events.TouchListener listener)Adds the listener to the collection of listeners who will be notified when touch events occur, by sending it one of the messages defined in theTouchListener
interface.NOTE: You must also call
setTouchEnabled(true)
to specify that touch events should be sent, which will cause gesture events to not be sent.Warning: This API is currently only implemented on Windows and Cocoa. SWT doesn't send Gesture or Touch events on GTK.
- Overrides:
addTouchListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.7
- See Also:
TouchListener
,removeTouchListener(org.eclipse.swt.events.TouchListener)
,setTouchEnabled(boolean)
-
forceFocus
public boolean forceFocus()Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.- Overrides:
forceFocus
in classorg.eclipse.swt.widgets.Control
- Returns:
true
if the control got focus, andfalse
if it was unable to.- Throws:
org.eclipse.swt.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:
setFocus()
-
isFocusControl
public boolean isFocusControl()Returnstrue
if the receiver has the user-interface focus, andfalse
otherwise.- Overrides:
isFocusControl
in classorg.eclipse.swt.widgets.Control
- Returns:
- the receiver's focus state
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
isPushMode
public boolean isPushMode()Returnstrue
if the eye button is a "push" button, andfalse
otherwise.- Returns:
- the eye button push mode
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
removeFocusListener
public void removeFocusListener(org.eclipse.swt.events.FocusListener listener)Removes the listener from the collection of listeners who will be notified when the control gains or loses focus.- Overrides:
removeFocusListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
FocusListener
,addFocusListener(org.eclipse.swt.events.FocusListener)
-
removeGestureListener
public void removeGestureListener(org.eclipse.swt.events.GestureListener listener)Removes the listener from the collection of listeners who will be notified when gesture events are generated for the control.- Overrides:
removeGestureListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.7
- See Also:
GestureListener
,addGestureListener(org.eclipse.swt.events.GestureListener)
-
removeHelpListener
public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.- Overrides:
removeHelpListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
HelpListener
,addHelpListener(org.eclipse.swt.events.HelpListener)
-
removeKeyListener
public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.- Overrides:
removeKeyListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
KeyListener
,addKeyListener(org.eclipse.swt.events.KeyListener)
-
removeMenuDetectListener
public void removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.- Overrides:
removeMenuDetectListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.3
- See Also:
MenuDetectListener
,addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener)
-
removeMouseTrackListener
public void removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)Removes the listener from the collection of listeners who will be notified when the mouse passes or hovers over controls.- Overrides:
removeMouseTrackListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseTrackListener
,addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener)
-
removeMouseListener
public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)Removes the listener from the collection of listeners who will be notified when mouse buttons are pressed and released.- Overrides:
removeMouseListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseListener
,addMouseListener(org.eclipse.swt.events.MouseListener)
-
removeMouseMoveListener
public void removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)Removes the listener from the collection of listeners who will be notified when the mouse moves.- Overrides:
removeMouseMoveListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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:
MouseMoveListener
,addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener)
-
removeMouseWheelListener
public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)Removes the listener from the collection of listeners who will be notified when the mouse wheel is scrolled.- Overrides:
removeMouseWheelListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.3
- See Also:
MouseWheelListener
,addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener)
-
removeTouchListener
public void removeTouchListener(org.eclipse.swt.events.TouchListener listener)Removes the listener from the collection of listeners who will be notified when touch events occur.- Overrides:
removeTouchListener
in classorg.eclipse.swt.widgets.Control
- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.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.7
- See Also:
TouchListener
,addTouchListener(org.eclipse.swt.events.TouchListener)
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color)Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.Note: This operation is a hint and may be overridden by the platform.
- Overrides:
setBackground
in classorg.eclipse.swt.widgets.Control
- Parameters:
color
- the new color (or null)- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setCapture
public void setCapture(boolean capture)If the argument istrue
, causes the receiver to have all mouse events delivered to it until the method is called withfalse
as the argument. Note that on some platforms, a mouse button must currently be down for capture to be assigned.- Overrides:
setCapture
in classorg.eclipse.swt.widgets.Control
- Parameters:
capture
-true
to capture the mouse, andfalse
to release it- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setClickImage
public void setClickImage(org.eclipse.swt.graphics.Image image)Set the image displayed when the "reveal button" is clicked.- Parameters:
image
- the new image. Ifnull
, the default image will be displayed.- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setCursor
public void setCursor(org.eclipse.swt.graphics.Cursor cursor)Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.When the mouse pointer passes over a control its appearance is changed to match the control's cursor.
- Overrides:
setCursor
in classorg.eclipse.swt.widgets.Control
- Parameters:
cursor
- the new cursor (or null)- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
org.eclipse.swt.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)Sets the receiver's drag detect state. If the argument istrue
, the receiver will detect drag gestures, otherwise these gestures will be ignored.- Overrides:
setDragDetect
in classorg.eclipse.swt.widgets.Control
- Parameters:
dragDetect
- the new drag detect state- Throws:
org.eclipse.swt.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.3
-
setFocus
public boolean setFocus()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 classorg.eclipse.swt.widgets.Composite
- Returns:
true
if the control got focus, andfalse
if it was unable to.- Throws:
org.eclipse.swt.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:
forceFocus()
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color)Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.Note: This operation is a hint and may be overridden by the platform.
- Overrides:
setForeground
in classorg.eclipse.swt.widgets.Control
- Parameters:
color
- the new color (or null)- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setMenu
public void setMenu(org.eclipse.swt.widgets.Menu menu)Sets the receiver's pop up menu to the argument. All controls may optionally have a pop up menu that is displayed when the user requests one for the control. The sequence of key strokes, button presses and/or button releases that are used to request a pop up menu is platform specific.Note: Disposing of a control that has a pop up menu will dispose of the menu. To avoid this behavior, set the menu to null before the control is disposed.
- Overrides:
setMenu
in classorg.eclipse.swt.widgets.Control
- Parameters:
menu
- the new pop up menu- Throws:
java.lang.IllegalArgumentException
-- ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu
- ERROR_INVALID_PARENT - if the menu is not in the same widget tree
- ERROR_INVALID_ARGUMENT - if the menu has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setToolTipText
public void setToolTipText(java.lang.String string)Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.
NOTE: This operation is a hint and behavior is platform specific, on Windows for CJK-style mnemonics of the form " (&C)" at the end of the tooltip text are not shown in tooltip.
- Overrides:
setToolTipText
in classorg.eclipse.swt.widgets.Control
- Parameters:
string
- the new tool tip text (or null)- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTouchEnabled
public void setTouchEnabled(boolean enabled)Sets whether this control should send touch events (by default controls do not). Setting this tofalse
causes the receiver to send gesture events instead. No exception is thrown if a touch-based input device is not detected (this can be determined withDisplay#getTouchEnabled()
).- Overrides:
setTouchEnabled
in classorg.eclipse.swt.widgets.Control
- Parameters:
enabled
- the new touch-enabled state- Throws:
org.eclipse.swt.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.7
- See Also:
Display.getTouchEnabled()
-
traverse
public boolean traverse(int traversal)Based on the argument, perform one of the expected platform traversal action. The argument should be one of the constants:SWT.TRAVERSE_ESCAPE
,SWT.TRAVERSE_RETURN
,SWT.TRAVERSE_TAB_NEXT
,SWT.TRAVERSE_TAB_PREVIOUS
,SWT.TRAVERSE_ARROW_NEXT
,SWT.TRAVERSE_ARROW_PREVIOUS
,SWT.TRAVERSE_PAGE_NEXT
andSWT.TRAVERSE_PAGE_PREVIOUS
.- Overrides:
traverse
in classorg.eclipse.swt.widgets.Control
- Parameters:
traversal
- the type of traversal- Returns:
- true if the traversal succeeded
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
traverse
public boolean traverse(int traversal, org.eclipse.swt.widgets.Event event)Performs a platform traversal action corresponding to aKeyDown
event.Valid traversal values are
SWT.TRAVERSE_NONE
,SWT.TRAVERSE_MNEMONIC
,SWT.TRAVERSE_ESCAPE
,SWT.TRAVERSE_RETURN
,SWT.TRAVERSE_TAB_NEXT
,SWT.TRAVERSE_TAB_PREVIOUS
,SWT.TRAVERSE_ARROW_NEXT
,SWT.TRAVERSE_ARROW_PREVIOUS
,SWT.TRAVERSE_PAGE_NEXT
andSWT.TRAVERSE_PAGE_PREVIOUS
. Iftraversal
isSWT.TRAVERSE_NONE
then the Traverse event is created with standard values based on the KeyDown event. Iftraversal
is one of the other traversal constants then the Traverse event is created with this detail, and itsdoit
is taken from the KeyDown event.- Overrides:
traverse
in classorg.eclipse.swt.widgets.Control
- Parameters:
traversal
- the type of traversal, orSWT.TRAVERSE_NONE
to compute this fromevent
event
- the KeyDown event- Returns:
true
if the traversal succeeded- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT if the event is null
org.eclipse.swt.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
-
traverse
public boolean traverse(int traversal, org.eclipse.swt.events.KeyEvent event)Performs a platform traversal action corresponding to aKeyDown
event.Valid traversal values are
SWT.TRAVERSE_NONE
,SWT.TRAVERSE_MNEMONIC
,SWT.TRAVERSE_ESCAPE
,SWT.TRAVERSE_RETURN
,SWT.TRAVERSE_TAB_NEXT
,SWT.TRAVERSE_TAB_PREVIOUS
,SWT.TRAVERSE_ARROW_NEXT
,SWT.TRAVERSE_ARROW_PREVIOUS
,SWT.TRAVERSE_PAGE_NEXT
andSWT.TRAVERSE_PAGE_PREVIOUS
. Iftraversal
isSWT.TRAVERSE_NONE
then the Traverse event is created with standard values based on the KeyDown event. Iftraversal
is one of the other traversal constants then the Traverse event is created with this detail, and itsdoit
is taken from the KeyDown event.- Overrides:
traverse
in classorg.eclipse.swt.widgets.Control
- Parameters:
traversal
- the type of traversal, orSWT.TRAVERSE_NONE
to compute this fromevent
event
- the KeyDown event- Returns:
true
if the traversal succeeded- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT if the event is null
org.eclipse.swt.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