Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class Combo

extends Composite
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class are controls that allow the user to choose an item from a list of items, or optionally enter a new value by typing it into an editable text field. Often, 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.

Styles:
DROP_DOWN, READ_ONLY, SIMPLE
Events:
DefaultSelection, Modify, Selection, Verify, OrientationChange

Note

Only one of the styles DROP_DOWN and SIMPLE may be specified.

Important Note

This class is not intended to be subclassed.

See Also
List, Combo snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv GdkRGBA
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
private boolean
pack-priv long
pack-priv boolean
pack-priv boolean
pack-priv int
pack-priv int
pack-priv GdkRGBA
pack-priv long
pack-priv long
pack-priv int
pack-priv String[]
pack-priv int
public static final int
LIMIT

the operating system limit for the number of characters that the text field in an instance of this class can hold

pack-priv long
pack-priv long
pack-priv boolean
pack-priv int
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

AccessConstructor and Description
public
Combo(Composite
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
)

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

Method Summary

Modifier and TypeMethod and Description
public void
add(String
the new item
string
)

Adds the argument to the end of the receiver's list.

public void
add(String
the new item
string
,
int
the index for the item
index
)

Adds the argument to the receiver's list at the given zero-relative index.

public void
addModifyListener(ModifyListener
the listener which should be notified
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 the ModifyListener interface.

public void
addSegmentListener(SegmentListener
the listener which should be notified
listener
)

Adds a segment listener.

public void
addSelectionListener(SelectionListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in the SelectionListener interface.

public void
addVerifyListener(VerifyListener
the listener which should be notified
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 the VerifyListener interface.

pack-priv void
adjustChildClipping(long
the handle to the widget
widget
)

Overrides org.eclipse.swt.widgets.Composite.adjustChildClipping.

Allows Controls to adjust the clipping of themselves or their children.
pack-priv static int
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Checks that this class can be subclassed.
pack-priv boolean
public void
clearSelection()

Sets the selection in the receiver's text field to an empty selection starting just before the first character.

pack-priv void
pack-priv Point
computeNativeSize(long h, int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Control.computeNativeSize.

pack-priv Point
computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Composite.computeSizeInPixels.

public void
copy()

Copies the selected text.

pack-priv void
public void
cut()

Cuts the selected text.

pack-priv GdkRGBA
pack-priv void
public void
deselect(int
the index of the item to deselect
index
)

Deselects the item at the given zero-relative index in the receiver's list.

public void
deselectAll()

Deselects all selected items in the receiver's list.

pack-priv boolean
dragDetect(int x, int y, boolean filter, boolean dragOnTimeout, boolean[] consume)

Overrides org.eclipse.swt.widgets.Control.dragDetect.

pack-priv long
pack-priv long
pack-priv long
pack-priv boolean
pack-priv long
pack-priv long
pack-priv long
pack-priv long
findPopupHandle(long oldList)

pack-priv void
pack-priv void
fixModal(long group, long modalGroup)

Overrides org.eclipse.swt.widgets.Composite.fixModal.

pack-priv long
pack-priv long
public Point

Returns:

a point, the location of the caret
getCaretLocation
()

Returns a point describing the location of the caret relative to the receiver.

pack-priv Point
public int

Returns:

the position of the caret
getCaretPosition
()

Returns the character position of the caret.

pack-priv GdkRGBA
pack-priv GdkRGBA
public String

Returns:

the item at the given index
getItem
(int
the index of the item to return
index
)

Returns the item at the given, zero-relative index in the receiver's list.

public int

Returns:

the number of items
getItemCount
()

Returns the number of items contained in the receiver's list.

public int

Returns:

the height of one item
getItemHeight
()

Returns the height of the area which would be used to display one of the items in the receiver's list.

public String[]

Returns:

the items in the receiver's list
getItems
()

Returns a (possibly empty) array of Strings which are the items in the receiver's list.

public boolean

Returns:

the receiver's list's visibility state
getListVisible
()

Returns true if the receiver's list is visible, and false otherwise.

pack-priv String
public int

Returns:

the orientation style
getOrientation
()

Overrides org.eclipse.swt.widgets.Control.getOrientation.

Returns the orientation of the receiver.
public Point

Returns:

a point representing the selection start and end
getSelection
()

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.

public int

Returns:

the index of the selected item
getSelectionIndex
()

Returns the zero-relative index of the item which is currently selected in the receiver's list, or -1 if no item is selected.

public String

Returns:

the receiver's text
getText
()

Returns a string containing a copy of the contents of the receiver's text field, or an empty string if there are no contents.

pack-priv String
getText(int start, int stop)

public int

Returns:

the text height
getTextHeight
()

Returns the height of the receivers's text field.

pack-priv int
public int

Returns:

the text limit
getTextLimit
()

Returns the maximum number of characters that the receiver's text field is capable of holding.

public int

Returns:

the number of items that are visible
getVisibleItemCount
()

Gets the number of items that are visible in the drop down portion of the receiver's list.

pack-priv long
pack-priv long
pack-priv long
private void
gtk_combo_box_insert(String string, int index)

private void
private void
gtk_combo_box_toggle_wrap(boolean wrap)

Bug 489640, 438992.

pack-priv long
gtk_commit(long imContext, long text)

Overrides org.eclipse.swt.widgets.Control.gtk_commit.

pack-priv long
gtk_delete_text(long widget, long start_pos, long end_pos)

Overrides org.eclipse.swt.widgets.Widget.gtk_delete_text.

pack-priv long
gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Composite.gtk_draw.

pack-priv long
pack-priv long
pack-priv long
gtk_insert_text(long widget, long new_text, long new_text_length, long position)

Overrides org.eclipse.swt.widgets.Widget.gtk_insert_text.

pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv boolean
pack-priv void
pack-priv void
hookEvents(long[] handles)

pack-priv long
public int

Returns:

the index of the item
indexOf
(String
the search item
string
)

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.

public int

Returns:

the index of the item
indexOf
(String
the search item
string
,
int
the zero-relative index at which to begin the search
start
)

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.

pack-priv boolean
pack-priv long
pack-priv long
public void
paste()

Pastes text from clipboard.

pack-priv void
pack-priv void
pack-priv void
public void
remove(int
the index for the item
index
)

Removes the item from the receiver's list at the given zero-relative index.

public void
remove(int
the start of the range
start
,
int
the end of the range
end
)

Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive).

public void
remove(String
the item to remove
string
)

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.

public void
removeAll()

Removes all of the items from the receiver's list and clear the contents of receiver's text field.

public void
removeModifyListener(ModifyListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.

public void
removeSegmentListener(SegmentListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.

public void
removeSelectionListener(SelectionListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.

public void
removeVerifyListener(VerifyListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the control is verified.

pack-priv Point
public void
select(int
the index of the item to select
index
)

Selects the item at the given zero-relative index in the receiver's list.

pack-priv void
pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Composite.setBounds.

pack-priv void
setButtonHandle(long widget)

pack-priv void
pack-priv void
pack-priv void
public void
setItem(int
the index for the item
index
,
String
the new text for the item
string
)

Sets the text of the item in the receiver's list at the given zero-relative index to the string argument.

public void
setItems(String...
the array of items
items
)

Sets the receiver's list to be the given array of items.

public void
setListVisible(boolean
the new visibility state
visible
)

Marks the receiver's list as visible if the argument is true, and marks it invisible otherwise.

pack-priv void
setMenuHandle(long widget)

pack-priv void
public void
setOrientation(int
new orientation style
orientation
)

Overrides org.eclipse.swt.widgets.Control.setOrientation.

Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
public void
setSelection(Point
a point representing the new selection start and end
selection
)

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.

public void
setText(String
the new text
string
)

Sets the contents of the receiver's text field to the given string.

public void
setTextLimit(int
new text limit
limit
)

Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument.

pack-priv void
public void
setVisibleItemCount(int
the new number of items to be visible
count
)

Sets the number of items that are visible in the drop down portion of the receiver's list.

pack-priv boolean
pack-priv void
pack-priv String
verifyText(String string, int start, int end)

Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListapplyThemeBackgroundchangedcheckBufferedcomputeTabListconnectFixedHandleDrawcreateHandledrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixParentGdkResourcefixStylefixTabListfixZOrderforceFocusgetBackgroundModegetChildrengetChildrenCountgetClientAreaInPixelsgetLayoutgetLayoutDeferredgetTabListgtk4_key_press_eventgtk_focusgtk_focus_in_eventgtk_mapgtk_realizegtk_scroll_childhasBorderhooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsprintWidgetpropagateDrawredrawChildrenreleaseChildrenremoveControlresizeHandlereskinChildrensetBackgroundModesetFocussetLayoutsetLayoutDeferredsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictraversalCodeupdateBackgroundModeupdateLayout