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

public Class CCombo

extends Composite
Class Inheritance
Imports
java.util.function.*, org.eclipse.swt.*, org.eclipse.swt.accessibility.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.widgets.*

The CCombo class represents a selectable user interface object that combines a text field and a list and issues notification when an item is selected from the list.

CCombo was written to work around certain limitations in the native combo box. Specifically, on win32, the height of a CCombo can be set; attempts to set the height of a Combo are ignored. CCombo can be used anywhere that having the increased flexibility is more important than getting native L&F, but the decision should not be taken lightly. There is no strict requirement that CCombo look or behave the same as the native combo box.

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:
BORDER, READ_ONLY, FLAT, LEAD, LEFT, CENTER, TRAIL, RIGHT
Events:
DefaultSelection, Modify, Selection, Verify
See Also
CCombo snippets, SWT Example: CustomControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Shell
pack-priv Button
pack-priv Color
pack-priv Listener
pack-priv Font
pack-priv Color
pack-priv boolean
pack-priv List
pack-priv Listener
pack-priv static final String
pack-priv Shell
pack-priv Text
pack-priv int
Inherited from org.eclipse.swt.widgets.Composite:
embeddedHandle

Constructor Summary

AccessConstructor and Description
public
CCombo(Composite
a widget which will be the parent of the new instance (cannot be null)
parent
,
int
the style of widget 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
pack-priv char
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
addSelectionListener(SelectionListener
the listener which should be notified when the user changes the receiver's selection
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
pack-priv static int
protected void
checkSubclass()

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

Checks that this class can be subclassed.
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
public Point
computeSize(int
the width hint (can be SWT.DEFAULT)
wHint
,
int
the height hint (can be SWT.DEFAULT)
hHint
,
boolean
true if the control's contents have changed, and false otherwise
changed
)

Overrides org.eclipse.swt.widgets.Control.computeSize.

Returns the preferred size (in points) of the receiver.
public void
copy()

Copies the selected text.

pack-priv void
createPopup(String[] items, int selectionIndex)

pack-priv void
createText(int comboStyle)

public void
cut()

Cuts the selected text.

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.

public int

Returns:

SWT.LEFT, SWT.RIGHT or SWT.CENTER
getAlignment
()

Returns the horizontal alignment.

pack-priv String
public Control[]
getChildren()

Overrides org.eclipse.swt.widgets.Composite.getChildren.

Returns a (possibly empty) array containing the receiver's children.
public boolean

Returns:

whether or not the receiver is editable
getEditable
()

Gets the editable state.

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

public Menu
getMenu()

Overrides org.eclipse.swt.widgets.Control.getMenu.

Returns the receiver's pop up menu if it has one, or null if it does not.
public Point

Returns:

a point representing the selection start and end
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.

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 Shell
getShell()

Overrides org.eclipse.swt.widgets.Control.getShell.

Returns the receiver's shell.
public int
getStyle()

Overrides org.eclipse.swt.widgets.Widget.getStyle.

Returns the receiver's style information.
public String

Returns:

the receiver's text
getText
()

Returns a string containing a copy of the contents of the receiver's text field.

public int

Returns:

the text height
getTextHeight
()

Returns the height of the receivers's text field.

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 void
handleFocus(int type)

pack-priv void
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 void
pack-priv void
internalLayout(boolean changed)

pack-priv boolean
public boolean
isFocusControl()

Overrides org.eclipse.swt.widgets.Control.isFocusControl.

Returns true if the receiver has the user-interface focus, and false otherwise.
pack-priv boolean
isParentScrolling(Control scrollableParent)

pack-priv void
public void
paste()

Pastes text from clipboard.

pack-priv void
public void
redraw()

Overrides org.eclipse.swt.widgets.Control.redraw.

Causes the entire bounds of the receiver to be marked as needing to be redrawn.
public void
redraw(int
the x coordinate of the area to draw
x
,
int
the y coordinate of the area to draw
y
,
int
the width of the area to draw
width
,
int
the height of the area to draw
height
,
boolean
true if children should redraw, and false otherwise
all
)

Overrides org.eclipse.swt.widgets.Control.redraw.

Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn.
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
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.

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.

public void
setAlignment(int
the alignment style of LEFT, RIGHT or CENTER
align
)

Set the horizontal alignment of the CCombo.

public void
setBackground(Color
the new color (or null)
color
)

Overrides org.eclipse.swt.widgets.Control.setBackground.

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.
public void
setEditable(boolean
the new editable state
editable
)

Sets the editable state.

public void
setEnabled(boolean
the new enabled state
enabled
)

Overrides org.eclipse.swt.widgets.Control.setEnabled.

Enables the receiver if the argument is true, and disables it otherwise.
public boolean
setFocus()

Overrides org.eclipse.swt.widgets.Composite.setFocus.

Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it.
public void
setFont(Font
the new font (or null)
font
)

Overrides org.eclipse.swt.widgets.Control.setFont.

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.
public void
setForeground(Color
the new color (or null)
color
)

Overrides org.eclipse.swt.widgets.Control.setForeground.

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.
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
setLayout(Layout
the receiver's new layout or null
layout
)

Overrides org.eclipse.swt.widgets.Composite.setLayout.

Sets the layout which is associated with the receiver to be the argument which may be null.
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.

public void
setMenu(Menu
the new pop up menu
menu
)

Overrides org.eclipse.swt.widgets.Control.setMenu.

Sets the receiver's pop up menu to the argument.
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.

public void
setToolTipText(String
the new tool tip text (or null)
string
)

Overrides org.eclipse.swt.widgets.Control.setToolTipText.

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.
public void
setVisible(boolean
the new visibility state
visible
)

Overrides org.eclipse.swt.widgets.Control.setVisible.

Marks the receiver as visible if the argument is true, and marks it invisible otherwise.
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 String
pack-priv void
public boolean
traverse(int
the type of traversal
event
)

Overrides org.eclipse.swt.widgets.Control.traverse.

Based on the argument, perform one of the expected platform traversal action.
Inherited from org.eclipse.swt.widgets.Composite:
changeddrawBackgroundgetBackgroundModegetLayoutgetLayoutDeferredgetTabListisLayoutDeferredlayoutlayoutlayoutlayoutlayoutsetBackgroundModesetLayoutDeferredsetTabListtoString