|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.widgets.Widget | +--org.eclipse.swt.widgets.Control | +--org.eclipse.swt.widgets.Scrollable | +--org.eclipse.swt.widgets.Composite | +--org.eclipse.swt.custom.CCombo
The CCombo class represents a selectable user interface object that combines a text field and a list and issues notificiation when an item is selected from the list.
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.
Field Summary |
Fields inherited from class org.eclipse.swt.widgets.Control |
handle |
Constructor Summary | |
CCombo(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(String string)
Adds an item. |
void |
add(String string,
int index)
Adds an item at an index. |
void |
addModifyListener(ModifyListener listener)
Adds the listener to receive events. |
void |
addSelectionListener(SelectionListener listener)
Adds the listener to receive events. |
void |
clearSelection()
Clears the current selection. |
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver. |
void |
deselect(int index)
Deselects an item. |
void |
deselectAll()
Deselects all items. |
Control[] |
getChildren()
Returns an array containing the receiver's children. |
String |
getItem(int index)
Gets an item at an index. |
int |
getItemCount()
Gets the number of items. |
int |
getItemHeight()
Gets the height of one item. |
String[] |
getItems()
Gets the items. |
Point |
getSelection()
Gets the selection. |
int |
getSelectionIndex()
Gets the index of the selected item. |
String |
getText()
Gets the widget text. |
int |
getTextHeight()
Gets the height of the combo's text field. |
int |
getTextLimit()
Gets the text limit. |
int |
indexOf(String string)
Gets the index of an item. |
int |
indexOf(String string,
int start)
Gets the index of an item. |
boolean |
isFocusControl()
Returns true if the receiver has the user-interface
focus, and false otherwise. |
void |
redraw(int x,
int y,
int width,
int height,
boolean all)
Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn. |
void |
remove(int index)
Removes an item at an index. |
void |
remove(int start,
int end)
Removes a range of items. |
void |
remove(String string)
Removes an item. |
void |
removeAll()
Removes all items. |
void |
removeModifyListener(ModifyListener listener)
Removes the listener. |
void |
removeSelectionListener(SelectionListener listener)
Removes the listener. |
void |
select(int index)
Selects an item. |
void |
setBackground(Color color)
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. |
boolean |
setFocus()
Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it. |
void |
setFont(Font font)
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. |
void |
setForeground(Color color)
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. |
void |
setItem(int index,
String string)
Sets the text of an item. |
void |
setItems(String[] items)
Sets all items. |
void |
setSelection(Point selection)
Sets the new selection. |
void |
setText(String string)
Sets the widget text |
void |
setTextLimit(int limit)
Sets the text limit |
void |
setToolTipText(String string)
Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown. |
Methods inherited from class org.eclipse.swt.widgets.Composite |
checkSubclass, getLayout, getTabList, layout, layout, setLayout, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Widget |
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CCombo(Composite parent, int style)
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.
parent
- a widget which will be the parent of the new instance (cannot be null)style
- the style of widget to construct
IllegalArgumentException
- SWTException
- SWT.BORDER
,
SWT.READ_ONLY
,
SWT.FLAT
,
Widget.getStyle()
Method Detail |
public void add(String string)
The item is placed at the end of the list. Indexing is zero based.
string
- the new item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when the string is null
SWTError(ERROR_ITEM_NOT_ADDED)
- when the item cannot be addedpublic void add(String string, int index)
The item is placed at an index in the list. Indexing is zero based. This operation will fail when the index is out of range.
string
- the new itemindex
- the index for the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when the string is null
SWTError(ERROR_ITEM_NOT_ADDED)
- when the item cannot be addedpublic void addModifyListener(ModifyListener listener)
listener
- the listener
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when listener is nullpublic void addSelectionListener(SelectionListener listener)
listener
- the listener
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when listener is nullpublic void clearSelection()
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic Point computeSize(int wHint, int hHint, boolean changed)
Control
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.
computeSize
in class Composite
wHint
- the width hint (can be SWT.DEFAULT
)hHint
- the height hint (can be SWT.DEFAULT
)changed
- true
if the control's contents have changed, and false
otherwise
Layout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack()
,
"computeTrim, getClientArea for controls that implement them"public void deselect(int index)
If the item at an index is selected, it is deselected. If the item at an index is not selected, it remains deselected. Indices that are out of range are ignored. Indexing is zero based.
index
- the index of the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic void deselectAll()
If an item is selected, it is deselected. If an item is not selected, it remains unselected.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic Control[] getChildren()
Composite
Note: This is not the actual structure used by the receiver to maintain its list of children, so modifying the array will not affect the receiver.
getChildren
in class Composite
public String getItem(int index)
Indexing is zero based. This operation will fail when the index is out of range or an item could not be queried from the OS.
index
- the index of the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_CANNOT_GET_ITEM)
- when the operation failspublic int getItemCount()
This operation will fail if the number of items could not be queried from the OS.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_CANNOT_GET_COUNT)
- when the operation failspublic int getItemHeight()
This operation will fail if the height of one item could not be queried from the OS.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT)
- when the operation failspublic String[] getItems()
This operation will fail if the items cannot be queried from the OS.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_CANNOT_GET_ITEM)
- when the operation failspublic Point getSelection()
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic int getSelectionIndex()
Indexing is zero based. If no item is selected -1 is returned.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic String getText()
If the widget has no text, an empty string is returned.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic int getTextHeight()
The operation will fail if the height cannot be queried from the OS.
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_ERROR_CANNOT_GET_ITEM_HEIGHT)
- when the operation failspublic int getTextLimit()
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic int indexOf(String string)
The list is searched starting at 0 until an item is found that is equal to the search item. If no item is found, -1 is returned. Indexing is zero based.
string
- the search item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when string is nullpublic int indexOf(String string, int start)
The widget is searched starting at start including the end position until an item is found that is equal to the search itenm. If no item is found, -1 is returned. Indexing is zero based.
string
- the search item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when string is nullpublic boolean isFocusControl()
Control
true
if the receiver has the user-interface
focus, and false
otherwise.
isFocusControl
in class Control
public void redraw(int x, int y, int width, int height, boolean all)
Control
all
flag
is true
, any children of the receiver which
intersect with the specified area will also paint their
intersecting areas. If the all
flag is
false
, the children will not be painted.
redraw
in class Control
x
- the x coordinate of the area to drawy
- the y coordinate of the area to drawwidth
- the width of the area to drawheight
- the height of the area to drawall
- true
if children should redraw, and false
otherwiseControl.update()
public void remove(int index)
Indexing is zero based. This operation will fail when the index is out of range or an item could not be removed from the OS.
index
- the index of the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_ITEM_NOT_REMOVED)
- when the operation failspublic void remove(int start, int end)
Indexing is zero based. The range of items is from the start index up to and including the end index. This operation will fail when the index is out of range or an item could not be removed from the OS.
start
- the start of the rangeend
- the end of the range
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_ITEM_NOT_REMOVED)
- when the operation failspublic void remove(String string)
This operation will fail when the item could not be removed from the OS.
string
- the search item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when string is null
SWTError(ERROR_ITEM_NOT_REMOVED)
- when the operation failspublic void removeAll()
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic void removeModifyListener(ModifyListener listener)
listener
- the listener
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when listener is nullpublic void removeSelectionListener(SelectionListener listener)
listener
- the listener
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when listener is nullpublic void select(int index)
If the item at an index is not selected, it is selected. Indices that are out of range are ignored. Indexing is zero based.
index
- the index of the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposedpublic void setBackground(Color color)
Control
setBackground
in class Control
color
- the new color (or null)public boolean setFocus()
Control
setFocus
in class Composite
true
if the control got focus, and false
if it was unable to.Control.forceFocus()
public void setFont(Font font)
Control
setFont
in class Control
font
- the new font (or null)public void setForeground(Color color)
Control
setForeground
in class Control
color
- the new color (or null)public void setItem(int index, String string)
Indexing is zero based. This operation will fail when the index is out of range or an item could not be changed in the OS.
index
- the index for the itemstring
- the item
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when items is null
SWTError(ERROR_ITEM_NOT_MODIFIED)
- when the operation failspublic void setItems(String[] items)
items
- the array of items
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when items is null
SWTError(ERROR_ITEM_NOT_ADDED)
- when the operation failspublic void setSelection(Point selection)
selection
- point representing the start and the end of the new selection
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when selection is nullpublic void setText(String string)
string
- the widget text
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_NULL_ARGUMENT)
- when string is nullpublic void setTextLimit(int limit)
limit
- new text limit
SWTError(ERROR_THREAD_INVALID_ACCESS)
- when called from the wrong thread
SWTError(ERROR_WIDGET_DISPOSED)
- when the widget has been disposed
SWTError(ERROR_CANNOT_BE_ZERO)
- when limit is 0public void setToolTipText(String string)
Control
setToolTipText
in class Control
string
- the new tool tip text (or null)
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |