Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.widgets
Class Combo  view Combo download Combo.java

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.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 org.eclipse.swt.widgets.Control
_getShell, addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeNativeSize, computeSize, computeTabGroup, computeTabRoot, defaultFont, drawGripper, eventHandle, fixFocus, forceFocus, getAccessible, getBackground, getBaseColor, getBgColor, getBounds, getEnabled, getFgColor, getFont, getFontDescription, getForeground, getIMCaretPos, getLayoutData, getLocation, getMenu, getMonitor, getParent, getPath, getShell, getSize, getTextColor, getToolTipText, getVisible, gtk_button_release_event, gtk_enter_notify_event, gtk_event_after, gtk_key_release_event, gtk_leave_notify_event, gtk_mnemonic_activate, gtk_motion_notify_event, gtk_preedit_changed, gtk_show_help, gtk_unrealize, gtk_visibility_notify_event, hoverProc, internal_dispose_GC, internal_new_GC, isEnabled, isFocusAncestor, isFocusControl, isReparentable, isShowing, isTabItem, isVisible, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, moveHandle, pack, pack, paintHandle, paintWindow, redraw, redraw, redrawWidget, releaseChild, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, sendFocusEvent, sendHelpEvent, sendIMKeyEvent, sendKeyEvent, sendMouseEvent, setBackground, setBackgroundColor, setBounds, setBounds, setCapture, setCursor, setCursor, setEnabled, setFont, setForeground, setInitialSize, setLayoutData, setLocation, setLocation, setMenu, setParent, setRadioSelection, setRedraw, setSize, setSize, setToolTipText, setVisible, setZOrder, setZOrder, showMenu, sort, toControl, toControl, toDisplay, toDisplay, translateMnemonic, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, update, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkOrientation, checkParent, checkWidget, destroyWidget, dispose, error, filterProc, filters, fixMnemonic, fontHeight, getData, getData, getDisplay, getName, getNameText, getStyle, gtk_clicked, gtk_configure_event, gtk_delete_event, gtk_delete_range, gtk_delete_text, gtk_event, gtk_hide, gtk_insert_text, gtk_map_event, gtk_row_activated, gtk_select, gtk_show, gtk_size_allocate, gtk_switch_page, gtk_test_collapse_row, gtk_test_expand_row, gtk_timer, gtk_toggled, gtk_unmap_event, gtk_value_changed, gtk_window_state_event, hooks, isDisposed, isListening, isValidSubclass, isValidThread, isValidWidget, menuPositionProc, mnemonicHit, mnemonicMatch, notifyListeners, pixbufCellDataProc, postEvent, postEvent, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, shellMapProc, textCellDataProc, timerProc, toString, translateTraversal, treeSelectionProc, windowProc, windowProc, windowProc, windowProc
 
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 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.

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 use add(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 ModifyListener interface.


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 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.


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.DEFAULT is 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 be false, so layout manager caches can be retained.

Overrides:
computeSize in class Composite

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:
createHandle in class Composite

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:
deregister in class Composite

filterKey

boolean filterKey(int keyval,
                  long event)
Overrides:
filterKey in class Control

fontHandle

long fontHandle()
Overrides:
fontHandle in class Control

focusHandle

long focusHandle()
Overrides:
focusHandle in class Composite

hasFocus

boolean hasFocus()
Overrides:
hasFocus in class Control

hookEvents

void hookEvents()
Overrides:
hookEvents in class Composite

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:
getBackgroundColor in class Control

getForegroundColor

org.eclipse.swt.internal.gtk.GdkColor getForegroundColor()
Overrides:
getForegroundColor in class Control

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 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. 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 constant Combo.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_activate in class Widget

gtk_changed

long gtk_changed(long widget)
Overrides:
gtk_changed in class Widget

gtk_commit

long gtk_commit(long imContext,
                long text)
Overrides:
gtk_commit in class Control

gtk_popup_menu

long gtk_popup_menu(long widget)
Overrides:
gtk_popup_menu in class Control

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:
parentingHandle in class Composite

register

void register()
Overrides:
register in class Composite

releaseHandle

void releaseHandle()
Overrides:
releaseHandle in class Scrollable

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:
setBackgroundColor in class Control

setBounds

boolean setBounds(int x,
                  int y,
                  int width,
                  int height,
                  boolean move,
                  boolean resize)
Overrides:
setBounds in class Composite

setFontDescription

void setFontDescription(long font)
Overrides:
setFontDescription in class Control

setForegroundColor

void setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
Overrides:
setForegroundColor in class Control

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 then add'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_RIGHT or SWT.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 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.


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:
translateTraversal in class Composite