|
|||||||||
| Home >> All >> org >> eclipse >> swt >> [ widgets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.swt.widgets
Class Combo

java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Combo
- All Implemented Interfaces:
- org.eclipse.swt.graphics.Drawable
- public class Combo
- extends Composite
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
Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
IMPORTANT: This class is not intended to be subclassed.
| Field Summary | |
(package private) long |
arrowHandle
|
(package private) long |
entryHandle
|
(package private) boolean |
ignoreSelect
|
(package private) static int |
INNER_BORDER
|
(package private) java.lang.String[] |
items
|
(package private) int |
lastEventTime
|
static int |
LIMIT
the operating system limit for the number of characters that the text field in an instance of this class can hold |
(package private) long |
listHandle
|
(package private) int |
visibleCount
|
| Fields inherited from class org.eclipse.swt.widgets.Composite |
embeddedHandle, imHandle, layout, socketHandle, tabList |
| Fields inherited from class org.eclipse.swt.widgets.Scrollable |
horizontalBar, scrolledHandle, verticalBar |
| Fields inherited from class org.eclipse.swt.widgets.Control |
accessible, cursor, drawCount, enableWindow, fixedHandle, font, layoutData, menu, parent, redrawWindow, toolTipText |
| Fields inherited from class org.eclipse.swt.widgets.Widget |
ACTIVATE, BUTTON_PRESS_EVENT, BUTTON_RELEASE_EVENT, CANVAS, CHANGED, CLICKED, COMMIT, CONFIGURE_EVENT, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_RANGE, DELETE_TEXT, DISABLED, display, DISPOSED, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPOSE_EVENT, FOCUS, FOCUS_IN_EVENT, FOCUS_OUT_EVENT, handle, HANDLE, HIDE, INSERT_TEXT, KEY_PRESS_EVENT, KEY_RELEASE_EVENT, KEYED_DATA, LEAVE_NOTIFY_EVENT, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MOTION_NOTIFY_EVENT, OBSCURED, POPUP_MENU, PREEDIT_CHANGED, REALIZE, ROW_ACTIVATED, SCROLL_CHILD, SELECT, SHOW, SHOW_HELP, SIZE_ALLOCATE, state, style, STYLE_SET, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TOGGLED, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT |
| Constructor Summary | |
Combo(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 | |
void |
add(java.lang.String string)
Adds the argument to the end of the receiver's list. |
void |
add(java.lang.String string,
int index)
Adds the argument to the receiver's list at the given zero-relative index. |
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 the ModifyListener
interface. |
void |
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
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. |
(package private) static int |
checkStyle(int style)
|
void |
clearSelection()
Sets the selection in the receiver's text field to an empty selection starting just before the first character. |
org.eclipse.swt.graphics.Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver. |
void |
copy()
Copies the selected text. |
(package private) void |
createHandle(int index)
|
void |
cut()
Cuts the selected text. |
(package private) void |
deregister()
|
void |
deselect(int index)
Deselects the item at the given zero-relative index in the receiver's list. |
void |
deselectAll()
Deselects all selected items in the receiver's list. |
(package private) boolean |
filterKey(int keyval,
long event)
|
(package private) long |
focusHandle()
|
(package private) long |
fontHandle()
|
(package private) org.eclipse.swt.internal.gtk.GdkColor |
getBackgroundColor()
|
(package private) org.eclipse.swt.internal.gtk.GdkColor |
getForegroundColor()
|
java.lang.String |
getItem(int index)
Returns the item at the given, zero-relative index in the receiver's list. |
int |
getItemCount()
Returns the number of items contained in the receiver's list. |
int |
getItemHeight()
Returns the height of the area which would be used to display one of the items in the receiver's list. |
java.lang.String[] |
getItems()
Returns an array of Strings which are the items
in the receiver's list. |
int |
getOrientation()
Returns the orientation of the receiver. |
org.eclipse.swt.graphics.Point |
getSelection()
Returns a Point whose x coordinate is the start
of the selection in the receiver's text field, and whose y
coordinate is the end of the selection. |
int |
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. |
java.lang.String |
getText()
Returns a string containing a copy of the contents of the receiver's text field. |
(package private) java.lang.String |
getText(int start,
int stop)
|
int |
getTextHeight()
Returns the height of the receivers's text field. |
int |
getTextLimit()
Returns the maximum number of characters that the receiver's text field is capable of holding. |
int |
getVisibleItemCount()
Gets the number of items that are visible in the drop down portion of the receiver's list. |
(package private) long |
gtk_activate(long widget)
|
(package private) long |
gtk_changed(long widget)
|
(package private) long |
gtk_commit(long imContext,
long text)
|
(package private) long |
gtk_popup_menu(long widget)
|
(package private) boolean |
hasFocus()
|
(package private) void |
hookEvents()
|
(package private) long |
imContext()
|
int |
indexOf(java.lang.String 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. |
int |
indexOf(java.lang.String string,
int 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. |
(package private) long |
parentingHandle()
|
void |
paste()
Pastes text from clipboard. |
(package private) void |
register()
|
(package private) void |
releaseHandle()
|
void |
remove(int index)
Removes the item from the receiver's list at the given zero-relative index. |
void |
remove(int start,
int end)
Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive). |
void |
remove(java.lang.String 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. |
void |
removeAll()
Removes all of the items from the receiver's list. |
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified. |
void |
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's selection changes. |
void |
select(int index)
Selects the item at the given zero-relative index in the receiver's list. |
(package private) void |
setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
|
(package private) boolean |
setBounds(int x,
int y,
int width,
int height,
boolean move,
boolean resize)
|
(package private) void |
setFontDescription(long font)
|
(package private) void |
setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
|
void |
setItem(int index,
java.lang.String string)
Sets the text of the item in the receiver's list at the given zero-relative index to the string argument. |
void |
setItems(java.lang.String[] items)
Sets the receiver's list to be the given array of items. |
(package private) void |
setItems(java.lang.String[] items,
boolean keepText,
boolean keepSelection)
|
void |
setOrientation(int orientation)
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT. |
void |
setSelection(org.eclipse.swt.graphics.Point 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. |
void |
setText(java.lang.String string)
Sets the contents of the receiver's text field to the given string. |
void |
setTextLimit(int limit)
Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument. |
void |
setVisibleItemCount(int count)
Sets the number of items that are visible in the drop down portion of the receiver's list. |
(package private) boolean |
translateTraversal(org.eclipse.swt.internal.gtk.GdkEventKey keyEvent)
|
| Methods inherited from class org.eclipse.swt.widgets.Composite |
_getChildren, _getTabList, checkSubclass, computeTabList, createHandle, enableWidget, findMenus, fixChildren, fixTabList, forceFocus, getChildren, getChildrenCount, getLayout, getTabList, gtk_button_press_event, gtk_expose_event, gtk_focus_in_event, gtk_focus_out_event, gtk_focus, gtk_key_press_event, gtk_realize, gtk_scroll_child, gtk_style_set, hasBorder, hooksKeys, imHandle, isTabGroup, layout, layout, minimumSize, moveAbove, moveBelow, releaseChildren, releaseWidget, removeControl, resizeHandle, setFocus, setLayout, setTabGroupFocus, setTabItemFocus, setTabList, translateMnemonic, traversalCode |
| Methods inherited from class org.eclipse.swt.widgets.Scrollable |
clientHandle, computeTrim, createScrollBar, createWidget, getBorderWidth, getClientArea, getHorizontalBar, getVerticalBar, hScrollBarWidth, setOrientation, topHandle, vScrollBarWidth |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
arrowHandle
long arrowHandle
entryHandle
long entryHandle
listHandle
long listHandle
lastEventTime
int lastEventTime
visibleCount
int visibleCount
items
java.lang.String[] items
ignoreSelect
boolean ignoreSelect
INNER_BORDER
static final int INNER_BORDER
- See Also:
- Constant Field Values
LIMIT
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
| Constructor Detail |
Combo
public Combo(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.
| Method Detail |
add
public void add(java.lang.String string)
- Adds the argument to the end of the receiver's list.
add
public void add(java.lang.String string, int index)
- Adds the argument to the receiver's list at the given
zero-relative index.
Note: To add an item at the end of the list, use the result of calling
getItemCount()as the index or useadd(String).
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 the
ModifyListenerinterface.
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
- 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
SelectionListenerinterface.widgetSelectedis called when the combo's list selection changes.widgetDefaultSelectedis typically called when ENTER is pressed the combo's text area.
checkStyle
static int checkStyle(int style)
clearSelection
public void clearSelection()
- Sets the selection in the receiver's text field to an empty
selection starting just before the first character. If the
text field is editable, this has the effect of placing the
i-beam at the start of the text.
Note: To clear the selected items in the receiver's list, use
deselectAll().
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
- Description copied from class:
Control - Returns the preferred size of the receiver.
The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant
SWT.DEFAULTis passed for the hint.If the changed flag is
true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will befalse, so layout manager caches can be retained.- Overrides:
computeSizein classComposite
copy
public void copy()
- Copies the selected text.
The current selection is copied to the clipboard.
- Since:
- 2.1
createHandle
void createHandle(int index)
- Overrides:
createHandlein classComposite
cut
public void cut()
- Cuts the selected text.
The current selection is first copied to the clipboard and then deleted from the widget.
- Since:
- 2.1
deregister
void deregister()
- Overrides:
deregisterin classComposite
filterKey
boolean filterKey(int keyval,
long event)
fontHandle
long fontHandle()
- Overrides:
fontHandlein classControl
focusHandle
long focusHandle()
- Overrides:
focusHandlein classComposite
hasFocus
boolean hasFocus()
hookEvents
void hookEvents()
- Overrides:
hookEventsin classComposite
imContext
long imContext()
deselect
public void deselect(int index)
- Deselects the item at the given zero-relative index in the receiver's
list. If the item at the index was already deselected, it remains
deselected. Indices that are out of range are ignored.
deselectAll
public void deselectAll()
- Deselects all selected items in the receiver's list.
Note: To clear the selection in the receiver's text field, use
clearSelection().
getBackgroundColor
org.eclipse.swt.internal.gtk.GdkColor getBackgroundColor()
- Overrides:
getBackgroundColorin classControl
getForegroundColor
org.eclipse.swt.internal.gtk.GdkColor getForegroundColor()
- Overrides:
getForegroundColorin classControl
getItem
public java.lang.String getItem(int index)
- Returns the item at the given, zero-relative index in the
receiver's list. Throws an exception if the index is out
of range.
getItemCount
public int getItemCount()
- Returns the number of items contained in the receiver's list.
getItemHeight
public int getItemHeight()
- Returns the height of the area which would be used to
display one of the items in the receiver's list.
getItems
public java.lang.String[] getItems()
- Returns an array of
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.
getOrientation
public int getOrientation()
- Returns the orientation of the receiver.
- Since:
- 2.1.2
getSelection
public org.eclipse.swt.graphics.Point getSelection()
- Returns a
Pointwhose x coordinate is the start of the selection in the receiver's text field, and whose y coordinate is the end of the selection. The returned values are zero-relative. An "empty" selection as indicated by the the x and y coordinates having the same value.
getSelectionIndex
public int 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.
getText
public java.lang.String getText()
- Returns a string containing a copy of the contents of the
receiver's text field.
getText
java.lang.String getText(int start, int stop)
getTextHeight
public int getTextHeight()
- Returns the height of the receivers's text field.
getTextLimit
public int getTextLimit()
- Returns the maximum number of characters that the receiver's
text field is capable of holding. If this has not been changed
by
setTextLimit(), it will be the constantCombo.LIMIT.
getVisibleItemCount
public int getVisibleItemCount()
- Gets the number of items that are visible in the drop
down portion of the receiver's list.
- Since:
- 3.0
gtk_activate
long gtk_activate(long widget)
- Overrides:
gtk_activatein classWidget
gtk_changed
long gtk_changed(long widget)
- Overrides:
gtk_changedin classWidget
gtk_commit
long gtk_commit(long imContext,
long text)
- Overrides:
gtk_commitin classControl
gtk_popup_menu
long gtk_popup_menu(long widget)
- Overrides:
gtk_popup_menuin classControl
indexOf
public int indexOf(java.lang.String 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. If no item
is found, returns -1.
indexOf
public int indexOf(java.lang.String string, int 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. If
no item is found or the starting index is out of range,
returns -1.
paste
public void paste()
- Pastes text from clipboard.
The selected text is deleted from the widget and new text inserted from the clipboard.
- Since:
- 2.1
parentingHandle
long parentingHandle()
- Overrides:
parentingHandlein classComposite
register
void register()
releaseHandle
void releaseHandle()
- Overrides:
releaseHandlein classScrollable
remove
public void remove(int index)
- Removes the item from the receiver's list at the given
zero-relative index.
remove
public void remove(int start,
int end)
- Removes the items from the receiver's list which are
between the given zero-relative start and end
indices (inclusive).
remove
public void remove(java.lang.String 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.
removeAll
public void removeAll()
- Removes all of the items from the receiver's list.
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.
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
- Removes the listener from the collection of listeners who will
be notified when the receiver's selection changes.
select
public void select(int index)
- Selects the item at the given zero-relative index in the receiver's
list. If the item at the index was already selected, it remains
selected. Indices that are out of range are ignored.
setBackgroundColor
void setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
- Overrides:
setBackgroundColorin classControl
setBounds
boolean setBounds(int x,
int y,
int width,
int height,
boolean move,
boolean resize)
setFontDescription
void setFontDescription(long font)
- Overrides:
setFontDescriptionin classControl
setForegroundColor
void setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
- Overrides:
setForegroundColorin classControl
setItem
public void setItem(int index,
java.lang.String string)
- Sets the text of the item in the receiver's list at the given
zero-relative index to the string argument. This is equivalent
to
remove'ing the old item at the index, and thenadd'ing the new item at that index.
setItems
public void setItems(java.lang.String[] items)
- Sets the receiver's list to be the given array of items.
setItems
void setItems(java.lang.String[] items, boolean keepText, boolean keepSelection)
setOrientation
public void setOrientation(int orientation)
- Sets the orientation of the receiver, which must be one
of the constants
SWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Since:
- 2.1.2
setSelection
public void setSelection(org.eclipse.swt.graphics.Point 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.
setText
public void setText(java.lang.String string)
- Sets the contents of the receiver's text field to the
given string.
Note: The text field in a
Combois 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.
setTextLimit
public void setTextLimit(int limit)
- Sets the maximum number of characters that the receiver's
text field is capable of holding to be the argument.
setVisibleItemCount
public void setVisibleItemCount(int count)
- Sets the number of items that are visible in the drop
down portion of the receiver's list.
- Since:
- 3.0
translateTraversal
boolean translateTraversal(org.eclipse.swt.internal.gtk.GdkEventKey keyEvent)
- Overrides:
translateTraversalin classComposite
|
|||||||||
| Home >> All >> org >> eclipse >> swt >> [ widgets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC