|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavabook.JavaBookDialog
javabook.ListBox
This dialog is for listing a list of items from which the user can select. You can get the index or the string value of the item the user selects. If the user closes the dialog without clicking any button or clicks the Cancel button, then the result is CANCEL (getSelectedIndex) or NO_ITEM (getSelectedItem). If the user clicks the OK button without selecting an item, then the result is CANCEL or NO_ITEM. If the user selects an item and clicks the OK button, then the index or the string value of the selected item is returned.
This class is provided as freeware. You are free to use as provided or modify to your heart's content. But you use it at your own risk. No implied or explicit warranty is given.
Field Summary | |
static int |
CANCEL
Constant to represent a user action where the Cancel button is clicked or the dialog is closed. |
static java.lang.String |
NO_ITEM
Constant to represent no selection for the getSelectedItem method. |
static int |
NO_SELECTION
Constant to represent a user action where the Ok button is clicked, but no item is selected from the list. |
Fields inherited from class javabook.JavaBookDialog |
ERROR_ICON, INFO_ICON, NO_ICON, QUESTION_ICON, WARNING_ICON |
Constructor Summary | |
ListBox(java.awt.Frame owner)
Constructs the standard modal ListBox dialog with 'owner' as its owner. |
|
ListBox(java.awt.Frame owner,
boolean modal)
Constructs a ListBox dialog with 'owner' as its owner and default title. |
|
ListBox(java.awt.Frame owner,
java.lang.String title)
Constructs a modal ListBox dialog with 'owner' as its owner and 'title' as its title. |
|
ListBox(java.awt.Frame owner,
java.lang.String title,
boolean modal)
Constructs a ListBox dialog with 'owner' as its owner and 'title' as its title. |
Method Summary | |
void |
addItem(java.lang.String item)
Adds an item to the list. |
void |
deleteItem(int index)
Deletes an item at position index from the list. |
void |
deleteItem(java.lang.String item)
Deletes an item from the list. |
java.lang.String |
getItemFromIndex(int index)
Returns the string value of an iten given index. |
int |
getSelectedIndex()
Prompts the user to select an item. |
java.lang.String |
getSelectedItem()
Prompts the user to select an item. |
Methods inherited from class javabook.JavaBookDialog |
setIcon, setLocation, setTitle |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NO_SELECTION
public static final int CANCEL
public static final java.lang.String NO_ITEM
Constructor Detail |
public ListBox(java.awt.Frame owner)
owner
- a Frame object owner of this dialogpublic ListBox(java.awt.Frame owner, java.lang.String title)
owner
- a Frame object owner of this dialogtitle
- the title of this titlepublic ListBox(java.awt.Frame owner, boolean modal)
owner
- a Frame object owner of this dialogmodal
- true for modal; false for modelesspublic ListBox(java.awt.Frame owner, java.lang.String title, boolean modal)
owner
- a Frame object owner of this dialogtitle
- the title of this titlemodal
- true for modal; false for modelessMethod Detail |
public void addItem(java.lang.String item)
item
- a String value to add to the listpublic void deleteItem(int index)
index
- the position of an item to removepublic void deleteItem(java.lang.String item)
item
- the item to removepublic int getSelectedIndex()
public java.lang.String getItemFromIndex(int index)
index
- the index of an item to return
public java.lang.String getSelectedItem()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |