Class DropDown
- All Implemented Interfaces:
- Adaptable
setVisibility(true)), the list
 appears attached to the control. The user can select an item from the list
 using the arrows keys and Enter, or the mouse.
 The list disappears automatically if the control looses focus, if an item is clicked,
 or if the escape key is pressed.
 This class supports the RWT.MARKUP_ENABLED property the same way Table and Tree do.
 
- Events:
- DefaultSelection, Selection
IMPORTANT: This class is not intended to be subclassed.
- Since:
- 2.3
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddListener(int eventType, Listener listener) Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.voiddispose()Disposes of the operating system resources associated with the receiver and all its descendents.<T> TgetAdapter(Class<T> adapter) Implementation of theAdaptableinterface.String[]getItems()Returns a (possibly empty) array ofStrings which are the items in the receiver.Returns the receiver's parent, which must be aControl.intReturns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.booleanReturnstrueif the receiver is visible, andfalseotherwise.intGets the number of items that are visible in the receiver's list.voidremoveListener(int eventType, Listener listener) Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.voidSets the application defined property of the receiver with the specified name to the given value.voidSets the receiver's items to be the given array of items.voidsetSelectionIndex(int selection) Selects the item at the given zero-relative index in the receiver.voidsetVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.voidsetVisibleItemCount(int itemCount) Sets the maximum number of items that are visible in the receiver's list.Methods inherited from class org.eclipse.swt.widgets.WidgetaddDisposeListener, checkSubclass, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, reskin, setData, toString
- 
Constructor Details- 
DropDownConstructs a new instance of this class given its parent and a style value describing its behavior.- Parameters:
- parent- a control, usually- Text, which will be the parent of the new instance (cannot be null)
- style- the style of widget to construct
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
 
- SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
 
- Since:
- 3.2
- See Also:
 
- 
DropDownConstructs a new instance of this class given its parent.- Parameters:
- parent- a control, usually- Text, which will be the parent of the new instance (cannot be null)
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
 
- SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
 
- See Also:
 
 
- 
- 
Method Details- 
setItemsSets the receiver's items to be the given array of items.- Parameters:
- items- the array of items
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the items array is null
- ERROR_INVALID_ARGUMENT - if an item in the items array is null
 
 
- 
getItemsReturns a (possibly empty) array ofStrings which are the items in the receiver.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. - Returns:
- the items in the receiver's list
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
setSelectionIndexpublic void setSelectionIndex(int selection) Selects the item at the given zero-relative index in the receiver. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.- Parameters:
- selection- the index of the item to select
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
getSelectionIndexpublic int getSelectionIndex()Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.- Returns:
- the index of the selected item or -1
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
setVisibleItemCountpublic void setVisibleItemCount(int itemCount) Sets the maximum number of items that are visible in the receiver's list.- Parameters:
- itemCount- the new number of items to be visible (default is 5)
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
getVisibleItemCountpublic int getVisibleItemCount()Gets the number of items that are visible in the receiver's list.- Returns:
- the number of items that are visible
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
setVisiblepublic void setVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.- Parameters:
- visible- the new visibility state
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
getVisiblepublic boolean getVisible()Returnstrueif the receiver is visible, andfalseotherwise.The initial value is false. - Returns:
- the receiver's visibility state
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
getParentReturns the receiver's parent, which must be aControl.- Returns:
- the receiver's parent
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- 
disposepublic void dispose()Description copied from class:WidgetDisposes of the operating system resources associated with the receiver and all its descendents. After this method has been invoked, the receiver and all descendents will answertruewhen sent the messageisDisposed(). Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection.NOTE: This method is not called recursively on the descendents of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the Disposeevent.
- 
setDataDescription copied from class:WidgetSets the application defined property of the receiver with the specified name to the given value.Applications may associate arbitrary objects with the receiver in this fashion. If the objects stored in the properties need to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. 
- 
addListenerDescription copied from class:WidgetAdds the listener to the collection of listeners who will be notified when an event of the given type occurs. When the event does occur in the widget, the listener is notified by sending it thehandleEvent()message. The event type is one of the event constants defined in classSWT.- Overrides:
- addListenerin class- Widget
- Parameters:
- eventType- the type of event to listen for
- listener- the listener which should be notified when the event occurs
- See Also:
 
- 
removeListenerDescription copied from class:WidgetRemoves the listener from the collection of listeners who will be notified when an event of the given type occurs. The event type is one of the event constants defined in classSWT.- Overrides:
- removeListenerin class- Widget
- Parameters:
- eventType- the type of event to listen for
- listener- the listener which should no longer be notified when the event occurs
- See Also:
 
- 
getAdapterDescription copied from class:WidgetImplementation of theAdaptableinterface.IMPORTANT: This method is not part of the RWT public API. It is marked public only so that it can be shared within the packages provided by RWT. It should never be accessed from application code. - Specified by:
- getAdapterin interface- Adaptable
- Overrides:
- getAdapterin class- Widget
- Parameters:
- adapter- the lookup class
- Returns:
- an object that can be cast to the given class or nullif there is no adapter associated with the given class.
 
 
-