org.eclipse.swt.widgets
Class List

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.List
All Implemented Interfaces:
Drawable, Runnable

public class List
extends Scrollable

Instances of this class are user interface objects that contain selectable items, displaying a list of strings and issuing notifications when a string is selected. A List may be of type single or multi select.

Styles:
SINGLE, MULTI
Events:
Selection, DefaultSelection

Note: Only one of SINGLE, and MULTI may be specified.

IMPORTANT: This class is not intended to be subclassed.


Field Summary
protected  int style
           
 
Fields inherited from class org.eclipse.swt.widgets.Widget
h, INCMD_DISPOSE, INCMD_EXTKEY, INCMD_KEY, INCMD_LDOWN, INCMD_LUP, INCMD_MENU, INCMD_POS, UPDATEITEM_ENABLED, UPDATEITEM_NAME, w, x, y
 
Constructor Summary
List(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 the argument to the end of the receiver's list.
 void add(String string, int index)
          Adds the argument to the specified position of the receiver's list.
 int getSelectionCount()
          Returns the number of currently selected items.
 int[] getSelectionIndices()
          Returns the zero-relative indices of the items which are currently selected in the receiver.
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getClientArea
 
Methods inherited from class org.eclipse.swt.widgets.Control
computeSize, computeSize, getLayoutData, isFocusControl, pack, pack, setBackground, setBounds, setFocus, setLayoutData, setSize, setSize, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addListener, dispose, focusState, getBorderWidth, getDisplayArea, getSelection, getStyle, getText, isDisposed, removeListener, setBounds, setCursor, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 
Methods inherited from interface org.eclipse.swt.graphics.Drawable
drawLine, drawRect, drawText, setColor
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

style

protected int style
Constructor Detail

List

public List(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.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT.SINGLE, SWT.MULTI
Method Detail

add

public void add(String string)
Adds the argument to the end of the receiver's list.

Parameters:
string - the new item
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTError -
  • ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure

add

public void add(String string,
                int index)
Adds the argument to the specified position of the receiver's list.

Parameters:
string - the new item
index - the position, -1 specifies the end of the list
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTError -
  • ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure

getSelectionCount

public int getSelectionCount()
Returns the number of currently selected items.

Returns:
the number of items currently selected
Throws:
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure

getSelectionIndices

public int[] getSelectionIndices()
Returns the zero-relative indices of the items which are currently selected in the receiver. The array is empty if no items are selected.

Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.

Returns:
the array of indices of the selected items
Throws:
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure