Combos are used in the same place
where a single selection List widget could
be used but space is limited. A Combo takes
less space than a List widget and shows
similar information.
Note: Since Combos can contain both a list
and an editable text field, it is possible to confuse methods
which access one versus the other (compare for example,
clearSelection() and deselectAll()).
The API documentation is careful to indicate either "the
receiver's list" or the "the receiver's text field" to
distinguish between the two cases.
Note that although this class is a subclass of Composite,
it does not make sense to add children to it, or set a layout on it.
Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
IMPORTANT: This class is not intended to be subclassed.
| Field Summary | |
|---|---|
| static int |
the operating system limit for the number of characters that the text field in an instance of this class can hold |
| Constructor Summary |
|---|
|
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. |
| Method Summary | |
|---|---|
| void |
Adds the argument to the end of the receiver's list. |
| void |
Adds the argument to the receiver's list at the given zero-relative index. |
| void |
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 the ModifyListener
interface.
|
| void |
Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener
interface.
|
| void |
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 the VerifyListener
interface.
|
| protected void |
No description provided. |
| void |
Sets the selection in the receiver's text field to an empty selection starting just before the first character. |
| Point |
No description provided. |
| void |
Copies the selected text. |
| void |
Cuts the selected text. |
| void |
Deselects the item at the given zero-relative index in the receiver's list. |
| void |
Deselects all selected items in the receiver's list. |
| String |
Returns the item at the given, zero-relative index in the receiver's list. |
| int |
Returns the number of items contained in the receiver's list. |
| int |
Returns the height of the area which would be used to display one of the items in the receiver's list. |
| String[] |
Returns a (possibly empty) array of Strings which are
the items in the receiver's list.
|
| int |
Returns the orientation of the receiver. |
| Point |
Returns a Point whose x coordinate is the
character position representing the start of the selection
in the receiver's text field, and whose y coordinate is the
character position representing the end of the selection.
|
| int |
Returns the zero-relative index of the item which is currently selected in the receiver's list, or -1 if no item is selected. |
| String |
Returns a string containing a copy of the contents of the receiver's text field, or an empty string if there are no contents. |
| int |
Returns the height of the receivers's text field. |
| int |
Returns the maximum number of characters that the receiver's text field is capable of holding. |
| int |
Gets the number of items that are visible in the drop down portion of the receiver's list. |
| int |
Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. |
| int |
Searches the receiver's list starting at the given, zero-relative index until an item is found that is equal to the argument, and returns the index of that item. |
| void |
Pastes text from clipboard. |
| void |
Removes the item from the receiver's list at the given zero-relative index. |
| void |
Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive). |
| void |
Searches the receiver's list starting at the first item until an item is found that is equal to the argument, and removes that item from the list. |
| void |
Removes all of the items from the receiver's list and clear the contents of receiver's text field. |
| void |
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified. |
| void |
Removes the listener from the collection of listeners who will be notified when the receiver's selection changes. |
| void |
Removes the listener from the collection of listeners who will be notified when the control is verified. |
| void |
Selects the item at the given zero-relative index in the receiver's list. |
| void |
No description provided. |
| void |
Sets the text of the item in the receiver's list at the given zero-relative index to the string argument. |
| void |
Sets the receiver's list to be the given array of items. |
| void |
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
|
| void |
Sets the selection in the receiver's text field to the range specified by the argument whose x coordinate is the start of the selection and whose y coordinate is the end of the selection. |
| void |
Sets the contents of the receiver's text field to the given string. |
| void |
Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument. |
| void |
Sets the number of items that are visible in the drop down portion of the receiver's list. |
| Methods inherited from org.eclipse.swt.graphicsDrawable |
|---|
| Methods inherited from java.langObject |
|---|
| Methods inherited from org.eclipse.swt.widgetsScrollable |
|---|
public static
int
LIMIT
The style value is either one of the style constants defined in
class SWT which is applicable to instances of this
class, or must be built by bitwise OR'ing together
(that is, using the int "|" operator) two or more
of those SWT style constants. The class description
lists the style constants that are applicable to the class.
Style bits are also inherited from superclasses.
Note: To add an item at the end of the list, use the
result of calling getItemCount() as the
index or use add(String).
ModifyListener
interface. SelectionListener
interface.
widgetSelected is called when the combo's list selection changes.
widgetDefaultSelected is typically called when ENTER is pressed the combo's text area.
VerifyListener
interface.
protected
void
checkSubclass
(
)
public
void
clearSelection
(
)
Note: To clear the selected items in the receiver's list,
use deselectAll().
public
void
copy
(
)
The current selection is copied to the clipboard.
public
void
cut
(
)
The current selection is first copied to the clipboard and then deleted from the widget.
public
void
deselect
(
int
index
)
public
void
deselectAll
(
)
Note: To clear the selection in the receiver's text field,
use clearSelection().
public
int
getItemCount
(
)
public
int
getItemHeight
(
)
Strings which are
the items in the receiver's list.
Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
public
int
getOrientation
(
)
Point whose x coordinate is the
character position representing the start of the selection
in the receiver's text field, 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.
public
int
getSelectionIndex
(
)
public
int
getTextHeight
(
)
public
int
getTextLimit
(
)
setTextLimit(), it will be the constant
Combo.LIMIT.
public
int
getVisibleItemCount
(
)
Note: This operation is a hint and is not supported on platforms that do not have this concept.
public
void
paste
(
)
The selected text is deleted from the widget and new text inserted from the clipboard.
public
void
remove
(
int
index
)
public
void
remove
(
int
start,
int
end
)
public
void
removeAll
(
)
public
void
select
(
int
index
)
public
void
setOrientation
(
int
orientation
)
SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
e
Note: The text field in a Combo is typically
only capable of displaying a single line of text. Thus,
setting the text to a string containing line breaks or
other special characters will probably cause it to
display incorrectly.
public
void
setTextLimit
(
int
limit
)
To reset this value to the default, use setTextLimit(Combo.LIMIT).
Specifying a limit value larger than Combo.LIMIT sets the
receiver's limit to Combo.LIMIT.
public
void
setVisibleItemCount
(
int
count
)
Note: This operation is a hint and is not supported on platforms that do not have this concept.