public class DropDown extends Widget
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.
IMPORTANT: This class is not intended to be subclassed.
Constructor and Description |
---|
DropDown(Control parent)
Constructs a new instance of this class given its parent.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(int eventType,
Listener listener)
Adds the listener to the collection of listeners who will be notified when
an event of the given type occurs.
|
void |
dispose()
Disposes of the operating system resources associated with
the receiver and all its descendents.
|
<T> T |
getAdapter(java.lang.Class<T> adapter)
Implementation of the
Adaptable interface. |
java.lang.String[] |
getItems()
Returns a (possibly empty) array of
String s which
are the items in the receiver. |
Control |
getParent()
Returns the receiver's parent, which must be a
Control . |
int |
getSelectionIndex()
Returns the zero-relative index of the item which is currently
selected in the receiver, or -1 if no item is selected.
|
boolean |
getVisible()
Returns
true if the receiver is visible, and
false otherwise. |
int |
getVisibleItemCount()
Gets the number of items that are visible in the receiver's list.
|
void |
removeListener(int eventType,
Listener listener)
Removes the listener from the collection of listeners who will
be notified when an event of the given type occurs.
|
void |
setData(java.lang.String key,
java.lang.Object value)
Sets the application defined property of the receiver
with the specified name to the given value.
|
void |
setItems(java.lang.String[] items)
Sets the receiver's items to be the given array of items.
|
void |
setSelectionIndex(int selection)
Selects the item at the given zero-relative index in the receiver.
|
void |
setVisible(boolean visible)
Marks the receiver as visible if the argument is
true ,
and marks it invisible otherwise. |
void |
setVisibleItemCount(int itemCount)
Sets the maximum number of items that are visible in the receiver's list.
|
addDisposeListener, checkSubclass, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, reskin, setData, toString
public DropDown(Control parent)
parent
- a control, usually Text
,
which will be the parent of the new instance (cannot be null)java.lang.IllegalArgumentException
- SWTException
- Text
,
Widget.checkSubclass()
public void setItems(java.lang.String[] items)
items
- the array of itemsSWTException
- java.lang.IllegalArgumentException
- public java.lang.String[] getItems()
String
s 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.
SWTException
- public void setSelectionIndex(int selection)
selection
- the index of the item to selectSWTException
- public int getSelectionIndex()
SWTException
- public void setVisibleItemCount(int itemCount)
itemCount
- the new number of items to be visible (default is 5)SWTException
- public int getVisibleItemCount()
SWTException
- public void setVisible(boolean visible)
true
,
and marks it invisible otherwise.visible
- the new visibility stateSWTException
- public boolean getVisible()
true
if the receiver is visible, and
false
otherwise.
The initial value is false.
SWTException
- public Control getParent()
Control
.SWTException
- public void dispose()
Widget
true
when sent the message isDisposed()
.
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 Dispose
event.
public void setData(java.lang.String key, java.lang.Object value)
Widget
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.
setData
in class Widget
key
- the name of the propertyvalue
- the new value for the propertyWidget.getData(String)
public void addListener(int eventType, Listener listener)
Widget
handleEvent()
message. The event type is one of the event constants defined in class
SWT
.addListener
in class Widget
eventType
- the type of event to listen forlistener
- the listener which should be notified when the event occursListener
,
SWT
,
Widget.removeListener(int, org.eclipse.swt.widgets.Listener)
,
Widget.notifyListeners(int, org.eclipse.swt.widgets.Event)
public void removeListener(int eventType, Listener listener)
Widget
IMPORTANT: This method is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It should never be referenced from application code.
removeListener
in class Widget
eventType
- the type of event to listen forlistener
- the listener which should no longer be notifiedListener
,
Widget.addListener(int, org.eclipse.swt.widgets.Listener)
public <T> T getAdapter(java.lang.Class<T> adapter)
Widget
Adaptable
interface.
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.
getAdapter
in interface Adaptable
getAdapter
in class Widget
adapter
- the lookup classnull
if
there is no adapter associated with the given class.
Copyright (c) EclipseSource and others 2002, 2014.
All rights reserved. This program and the accompanying materials
are made available under the terms of the
Eclipse Public License v1.0