Class PasswordRevealer
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.eclipse.nebula.widgets.passwordrevealer.PasswordRevealer
-
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class PasswordRevealer extends org.eclipse.swt.widgets.CompositeInstances of this class are selectable user interface objects that allow the user to enter and modify passwords. A "eye" button is drawned on the right side of the widget. When one clicks on the button, the password is revealed, and when the user stops clicking the password is displayed with dots.- Styles:
- CENTER, ICON_CANCEL, ICON_SEARCH, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP
- 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 private org.eclipse.swt.widgets.Compositecompprivate chardefaultEchoCharprivate EyeButtoneyeButtonprotected org.eclipse.swt.widgets.TextpasswordField
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddControlListener(org.eclipse.swt.events.ControlListener listener)Adds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in theControlListenerinterface.voidaddDragDetectListener(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 theDragDetectListenerinterface.voidaddFocusListener(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 theFocusListenerinterface.voidaddGestureListener(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 theGestureListenerinterface.voidaddHelpListener(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 theHelpListenerinterface.voidaddKeyListener(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 theKeyListenerinterface.voidaddMenuDetectListener(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 theMenuDetectListenerinterface.voidaddModifyListener(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 theModifyListenerinterface.voidaddMouseListener(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 theMouseListenerinterface.voidaddMouseMoveListener(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 theMouseMoveListenerinterface.voidaddMouseTrackListener(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 theMouseTrackListenerinterface.voidaddMouseWheelListener(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 theMouseWheelListenerinterface.voidaddSegmentListener(org.eclipse.swt.events.SegmentListener listener)Adds a segment listener.voidaddSelectionListener(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 theSelectionListenerinterface.voidaddTouchListener(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 theTouchListenerinterface.voidaddVerifyListener(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 theVerifyListenerinterface.voidappend(java.lang.String string)Appends a string.voidclearSelection()Clears the selection.voidcopy()Copies the selected text.voidcut()Cuts the selected text.booleanforceFocus()Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.intgetCaretLineNumber()Returns the line number of the caret.org.eclipse.swt.graphics.PointgetCaretLocation()Returns a point describing the location of the caret relative to the receiver.intgetCaretPosition()Returns the character position of the caret.intgetCharCount()Returns the number of characters.org.eclipse.swt.graphics.ImagegetClickImage()Returns the image displayed when the "reveal button" is clicked.booleangetDoubleClickEnabled()Returns the double click enabled flag.chargetEchoChar()Returns the echo character.booleangetEditable()Returns the editable state.org.eclipse.swt.graphics.ImagegetImage()Returns the image used when the user wants to reveal the password of lines.intgetLineCount()Returns the number of lines.java.lang.StringgetLineDelimiter()Returns the line delimiter.intgetLineHeight()Returns the height of a line.java.lang.StringgetMessage()Returns the widget message.org.eclipse.swt.graphics.PointgetSelection()Returns aPointwhose 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.intgetSelectionCount()Returns the number of selected characters.java.lang.StringgetSelectionText()Gets the selected text, or an empty string if there is no current selection.intgetTabs()Returns the number of tabs.java.lang.StringgetText()Returns the widget text.java.lang.StringgetText(int start, int end)Returns a range of text.char[]getTextChars()Returns the widget's text as a character array.intgetTextLimit()Returns the maximum number of characters that the receiver is capable of holding.intgetTopIndex()Returns the zero-relative index of the line which is currently at the top of the receiver.intgetTopPixel()Returns the zero-relative index of the line which is currently at the top of the receiver.(package private) voidhidePassword()voidinsert(java.lang.String string)Inserts a string.booleanisFocusControl()Returnstrueif the receiver has the user-interface focus, andfalseotherwise.voidpaste()Pastes text from clipboard.voidremoveControlListener(org.eclipse.swt.events.ControlListener listener)Removes the listener from the collection of listeners who will be notified when the control is moved or resized.private intremoveFields(int original, int... styles)voidremoveFocusListener(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.voidremoveGestureListener(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.voidremoveHelpListener(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.voidremoveKeyListener(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.voidremoveMenuDetectListener(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.voidremoveModifyListener(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.voidremoveMouseListener(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.voidremoveMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)Removes the listener from the collection of listeners who will be notified when the mouse moves.voidremoveMouseTrackListener(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.voidremoveMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)Removes the listener from the collection of listeners who will be notified when the mouse wheel is scrolled.voidremoveSegmentListener(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.voidremoveSelectionListener(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.voidremoveTouchListener(org.eclipse.swt.events.TouchListener listener)Removes the listener from the collection of listeners who will be notified when touch events occur.voidremoveVerifyListener(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) voidrevealPassword()voidselectAll()Selects all the text in the receiver.voidsetBackground(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.voidsetCapture(boolean capture)If the argument istrue, causes the receiver to have all mouse events delivered to it until the method is called withfalseas the argument.voidsetClickImage(org.eclipse.swt.graphics.Image image)Set the image displayed when the "reveal button" is clicked.voidsetCursor(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.voidsetDoubleClickEnabled(boolean doubleClick)Sets the double click enabled flag.voidsetDragDetect(boolean dragDetect)Sets the receiver's drag detect state.voidsetEchoChar(char echo)Sets the echo character.voidsetEditable(boolean editable)Sets the editable state.booleansetFocus()Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it.voidsetFont(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.voidsetForeground(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.voidsetImage(org.eclipse.swt.graphics.Image image)Sets the image on which the user should click if he wants to reveal the password.voidsetMenu(org.eclipse.swt.widgets.Menu menu)Sets the receiver's pop up menu to the argument.voidsetMessage(java.lang.String message)Sets the widget message.voidsetOrientation(int orientation)Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.voidsetSelection(int start)Sets the selection.voidsetSelection(int start, int end)Sets the selection to the range specified by the given start and end indices.voidsetSelection(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.voidsetTabs(int tabs)Sets the number of tabs.voidsetText(java.lang.String string)Sets the contents of the receiver to the given string.voidsetTextChars(char[] text)Sets the contents of the receiver to the characters in the array.voidsetTextLimit(int limit)Sets the maximum number of characters that the receiver is capable of holding to be the argument.voidsetToolTipText(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.voidsetTopIndex(int index)Sets the zero-relative index of the line which is currently at the top of the receiver.voidsetTouchEnabled(boolean enabled)Sets whether this control should send touch events (by default controls do not).voidshowSelection()Shows the selection.booleantraverse(int traversal)Based on the argument, perform one of the expected platform traversal action.booleantraverse(int traversal, org.eclipse.swt.events.KeyEvent event)Performs a platform traversal action corresponding to aKeyDownevent.booleantraverse(int traversal, org.eclipse.swt.widgets.Event event)Performs a platform traversal action corresponding to aKeyDownevent.-
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
-
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
-
Methods inherited from class org.eclipse.swt.widgets.Control
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, isAutoScalable, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, 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, toString
-
-
-
-
Field Detail
-
passwordField
protected org.eclipse.swt.widgets.Text passwordField
-
eyeButton
private final EyeButton eyeButton
-
comp
private final org.eclipse.swt.widgets.Composite comp
-
defaultEchoChar
private final char defaultEchoChar
-
-
Constructor Detail
-
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
SWTwhich 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 thoseSWTstyle 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 Detail
-
removeFields
private int removeFields(int original, int... styles)
-
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 theModifyListenerinterface.- 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
SegmentEventis 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.
SegmentEvents 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 theSelectionListenerinterface.widgetSelectedis not called for texts.widgetDefaultSelectedis 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_CANCELstyle and the user cancels the search, the event object detail field contains the valueSWT.ICON_CANCEL. Likewise, if the receiver has theSWT.ICON_SEARCHstyle 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 theVerifyListenerinterface.- 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
nullit 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.
nullmeans 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 aPointwhose 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.SegmentsorSWT.Verifylistener 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:
setFontin 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_RIGHTorSWT.RIGHT_TO_LEFT.Note: This operation is a hint and is not supported on platforms that do not have this concept.
- Overrides:
setOrientationin 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
- Since:
- 2.1.2
-
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.SINGLEand 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.SegmentsorSWT.Verifylistener 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.LIMITsets 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
-
addControlListener
public void addControlListener(org.eclipse.swt.events.ControlListener listener)
Adds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in theControlListenerinterface.- Overrides:
addControlListenerin 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:
ControlListener,removeControlListener(org.eclipse.swt.events.ControlListener)
-
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 theDragDetectListenerinterface.- Overrides:
addDragDetectListenerin 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 theFocusListenerinterface.- Overrides:
addFocusListenerin 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 theGestureListenerinterface.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:
addGestureListenerin 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 theHelpListenerinterface.- Overrides:
addHelpListenerin 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 theKeyListenerinterface.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:
addKeyListenerin 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 theMenuDetectListenerinterface.- Overrides:
addMenuDetectListenerin 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 theMouseListenerinterface.- Overrides:
addMouseListenerin 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 theMouseTrackListenerinterface.- Overrides:
addMouseTrackListenerin 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 theMouseMoveListenerinterface.- Overrides:
addMouseMoveListenerin 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 theMouseWheelListenerinterface.- Overrides:
addMouseWheelListenerin 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 theTouchListenerinterface.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:
addTouchListenerin 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:
forceFocusin classorg.eclipse.swt.widgets.Control- Returns:
trueif the control got focus, andfalseif 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()
Returnstrueif the receiver has the user-interface focus, andfalseotherwise.- Overrides:
isFocusControlin 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
-
removeControlListener
public void removeControlListener(org.eclipse.swt.events.ControlListener listener)
Removes the listener from the collection of listeners who will be notified when the control is moved or resized.- Overrides:
removeControlListenerin 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:
ControlListener,addControlListener(org.eclipse.swt.events.ControlListener)
-
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:
removeFocusListenerin 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:
removeGestureListenerin 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:
removeHelpListenerin 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:
removeKeyListenerin 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:
removeMenuDetectListenerin 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:
removeMouseTrackListenerin 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:
removeMouseListenerin 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:
removeMouseMoveListenerin 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:
removeMouseWheelListenerin 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:
removeTouchListenerin 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:
setBackgroundin 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 withfalseas the argument. Note that on some platforms, a mouse button must currently be down for capture to be assigned.- Overrides:
setCapturein classorg.eclipse.swt.widgets.Control- Parameters:
capture-trueto capture the mouse, andfalseto 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:
setCursorin 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:
setDragDetectin 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:
setFocusin classorg.eclipse.swt.widgets.Composite- Returns:
trueif the control got focus, andfalseif 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:
setForegroundin 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:
setMenuin 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:
setToolTipTextin 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 tofalsecauses 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:
setTouchEnabledin 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_NEXTandSWT.TRAVERSE_PAGE_PREVIOUS.- Overrides:
traversein 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 aKeyDownevent.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_NEXTandSWT.TRAVERSE_PAGE_PREVIOUS. IftraversalisSWT.TRAVERSE_NONEthen the Traverse event is created with standard values based on the KeyDown event. Iftraversalis one of the other traversal constants then the Traverse event is created with this detail, and itsdoitis taken from the KeyDown event.- Overrides:
traversein classorg.eclipse.swt.widgets.Control- Parameters:
traversal- the type of traversal, orSWT.TRAVERSE_NONEto compute this fromeventevent- the KeyDown event- Returns:
trueif 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 aKeyDownevent.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_NEXTandSWT.TRAVERSE_PAGE_PREVIOUS. IftraversalisSWT.TRAVERSE_NONEthen the Traverse event is created with standard values based on the KeyDown event. Iftraversalis one of the other traversal constants then the Traverse event is created with this detail, and itsdoitis taken from the KeyDown event.- Overrides:
traversein classorg.eclipse.swt.widgets.Control- Parameters:
traversal- the type of traversal, orSWT.TRAVERSE_NONEto compute this fromeventevent- the KeyDown event- Returns:
trueif 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
-