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

public Class PopupList

extends Object
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.widgets.*

A PopupList is a list of selectable items that appears in its own shell positioned above its parent shell. It is used for selecting items when editing a Table cell (similar to the list that appears when you open a Combo box). The list will be positioned so that it does not run off the screen and the largest number of items are visible. It may appear above the current cursor location or below it depending how close you are to the edge of the screen.
See Also
Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv List
pack-priv int
pack-priv Shell

Constructor Summary

AccessConstructor and Description
public
PopupList(Shell
a Shell control which will be the parent of the new instance (cannot be null)
parent
)

Creates a PopupList above the specified shell.

public
PopupList(Shell
a widget which will be the parent of the new instance (cannot be null)
parent
,
int
the style of widget to construct
style
)

Creates a PopupList above the specified shell.

Method Summary

Modifier and TypeMethod and Description
private static int
checkStyle(int style)

public Font

Returns:

the widget font
getFont
()

Gets the widget font.

public String[]

Returns:

the items in the widget
getItems
()

Gets the items.

public int

Returns:

the minimum width of the list
getMinimumWidth
()

Gets the minimum width of the list.

public String

Returns:

the text of the selected item or null if no item is selected
open
(Rectangle
the initial size and location of the PopupList; the dialog will be positioned so that it does not run off the screen and the largest number of items are visible
rect
)

Launches the Popup List, waits for an item to be selected and then closes the PopupList.

public void
select(String
the text of the item
string
)

Selects an item with text that starts with specified String.

public void
setFont(Font
the new font (or null)
font
)

Sets the widget font.

public void
setItems(String[]
the array of items This operation will fail when an item is null or could not be added in the OS.
strings
)

Sets all items.

public void
setMinimumWidth(int
the minimum width of the list
width
)

Sets the minimum width of the list.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listback to summary
pack-priv List list
minimumWidthback to summary
pack-priv int minimumWidth
shellback to summary
pack-priv Shell shell

Constructor Detail

PopupListback to summary
public PopupList(Shell parent)

Creates a PopupList above the specified shell.

Parameters
parent:Shell

a Shell control which will be the parent of the new instance (cannot be null)

PopupListback to summary
public PopupList(Shell parent, int style)

Creates a PopupList above the specified shell.

Parameters
parent:Shell

a widget which will be the parent of the new instance (cannot be null)

style:int

the style of widget to construct

Since
3.0

Method Detail

checkStyleback to summary
private static int checkStyle(int style)
getFontback to summary
public Font getFont()

Gets the widget font.

Returns:Font

the widget font

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getItemsback to summary
public String[] getItems()

Gets the items.

This operation will fail if the items cannot be queried from the OS.

Returns:String[]

the items in the widget

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getMinimumWidthback to summary
public int getMinimumWidth()

Gets the minimum width of the list.

Returns:int

the minimum width of the list

openback to summary
public String open(Rectangle rect)

Launches the Popup List, waits for an item to be selected and then closes the PopupList.

Parameters
rect:Rectangle

the initial size and location of the PopupList; the dialog will be positioned so that it does not run off the screen and the largest number of items are visible

Returns:String

the text of the selected item or null if no item is selected

selectback to summary
public void select(String string)

Selects an item with text that starts with specified String.

If the item is not currently selected, it is selected. If the item at an index is selected, it remains selected. If the string is not matched, it is ignored.

Parameters
string:String

the text of the item

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setFontback to summary
public void setFont(Font font)

Sets the widget font.

When new font is null, the font reverts to the default system font for the widget.

Parameters
font:Font

the new font (or null)

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setItemsback to summary
public void setItems(String[] strings)

Sets all items.

The previous selection is cleared. The previous items are deleted. The new items are added. The top index is set to 0.

Parameters
strings:String[]

the array of items This operation will fail when an item is null or could not be added in the OS.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the items array is null
  • ERROR_INVALID_ARGUMENT - if an item in the items array is null
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setMinimumWidthback to summary
public void setMinimumWidth(int width)

Sets the minimum width of the list.

Parameters
width:int

the minimum width of the list