|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.ceryle.ui.SelectionDialog
public class SelectionDialog
A subclass of JDialog providing a selection list populated by a List. It can also be directly populated by a JList containing its contents. AbstractListModel, Vector, Enumeration or Iterator containing the list contents. This dialog is hidden upon button action and must be disposed of manually. The result is obtained via getSelection():
SelectionDialog dlog = new SelectionDialog(
myJFrame,
"dialog title",
"dialog message",
"optional description",
myList.iterator(),
SelectionDialog.SINGLE_SELECTION );
Collection selection = dlog.getSelection();
Following use of the dialog, the button pressed can be obtained
by calling getSelectedButton(), which returns one of
the following JOptionPane values:
If the dialog is closed via its window being closed, JOptionPane.CANCEL_OPTION is returned.
| Nested Class Summary | |
|---|---|
class |
SelectionDialog.DialogDisposer
|
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
Dialog.AccessibleAWTDialog |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
Window.AccessibleAWTWindow |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected JButton |
btn_all
|
protected JButton |
btn_cancel
|
protected JButton |
btn_extra
|
protected JButton |
btn_help
|
protected JButton |
btn_none
|
protected JButton |
btn_select
|
static int |
DEFAULT_COLUMN_WIDTH
The default column width (in characters) for the display list. |
static int |
DEFAULT_ROW_COUNT
The default number of rows to show in the display list. |
protected JTextArea |
help
|
protected JPanel |
helpPanel
|
protected JPanel |
m_centerPanel
|
protected JList |
m_list
|
protected SetModel |
m_listModel
|
protected JPanel |
m_northPanel
|
protected JPanel |
m_southPanel
|
protected MessageHandler |
mh
|
static int |
MIN_HEIGHT
Minimum window height in pixels. |
static int |
MIN_WIDTH
Minimum window width in pixels. |
static int |
MULTIPLE_INTERVAL_SELECTION
A value for the selectionMode property: select one or more contiguous ranges of indices at a time. |
protected int |
selectedButton
|
static int |
SINGLE_INTERVAL_SELECTION
A value for the selectionMode property: select one contiguous range of indices at a time. |
static int |
SINGLE_SELECTION
A value for the selectionMode property: select one list index at a time. |
protected Services |
srvs
|
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
SelectionDialog(Frame frame,
String title,
String message,
String description,
Object contents,
ListCellRenderer renderer,
int selectionMode)
Auto-display Constructor. |
|
SelectionDialog(Frame frame,
String title,
String message,
String description,
Object contents,
ListCellRenderer renderer,
int selectionMode,
boolean initVisible)
Constructor for a dialog box containing a selection list. |
|
| Method Summary | |
|---|---|
protected void |
addNavigationButtons(JPanel panel)
An extension method that does nothing in this class, permits buttons to be added to the left side of the south button panel. |
protected JPanel |
createCenterPanel(int selectionMode,
String description)
Returns the center panel containing the selection area(s) and optional help text. |
protected JPanel |
createNorthPanel(String message)
Returns the northernmost panel containing the message text. |
protected JPanel |
createSouthPanel(int selectionMode,
boolean includeHelp)
Returns the southernmost panel containing the submit and cancel buttons. |
JButton |
getExtraButton()
Returns the unused 'extra' button so that it can be configured externally. |
int |
getSelectedButton()
Returns the value of the selected button as one of the JOptionPane options JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, or JOptionPane.CANCEL_OPTION. |
int |
getSelectedCount()
Returns the number of selected items in the list. |
int[] |
getSelectedIndices()
Returns the selected indices, an empty array if there is no selection. |
Object |
getSelectedValue()
Returns the selected Object, null if there is no selection. |
Collection |
getSelectedValues()
Returns the selected Objects as a Collection, null if there is no selection. |
Collection |
getSelection()
Returns the selected item(s) of this SelectionList as a Collection of Strings, null if there is no selection or the user cancelled the dialog. |
boolean |
isHelpVisible()
|
void |
removeAllButton()
Removes the 'All' button. |
void |
removeNoneButton()
Removes the 'None' button. |
void |
setActive(boolean active)
Sets the active/inactive state of this dialog box, as indicated by the south panel colors. |
void |
setContents(Object o)
If provided with a ListModel, sets the list contents to that model, otherwise replaces the existing model with the contents of the provided Object. |
void |
setHelpText(String content)
Set the help text to the String content. |
void |
setListTitle(String title,
String message)
Sets the title of the list to title and message. |
void |
setSelected(Object o)
Set the selection to the provided object, which is added to the list if it is not already a member. |
protected void |
setSelectedButton(int value)
|
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SINGLE_SELECTION
ListSelectionModel.SINGLE_SELECTION,
Constant Field Valuespublic static final int SINGLE_INTERVAL_SELECTION
ListSelectionModel.SINGLE_INTERVAL_SELECTION,
Constant Field Valuespublic static final int MULTIPLE_INTERVAL_SELECTION
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION,
Constant Field Valuespublic static int MIN_WIDTH
public static int MIN_HEIGHT
public static int DEFAULT_COLUMN_WIDTH
public static int DEFAULT_ROW_COUNT
protected Services srvs
protected MessageHandler mh
protected SetModel m_listModel
protected JList m_list
protected int selectedButton
protected JButton btn_help
protected JButton btn_cancel
protected JButton btn_all
protected JButton btn_none
protected JButton btn_extra
protected JButton btn_select
protected JPanel m_northPanel
protected JPanel m_centerPanel
protected JPanel m_southPanel
protected JPanel helpPanel
protected JTextArea help
| Constructor Detail |
|---|
public SelectionDialog(Frame frame,
String title,
String message,
String description,
Object contents,
ListCellRenderer renderer,
int selectionMode)
public SelectionDialog(Frame frame,
String title,
String message,
String description,
Object contents,
ListCellRenderer renderer,
int selectionMode,
boolean initVisible)
Note that even the provided list is optional. If null, the dialog will still be displayed, but with no displayed list.
frame - the parent frametitle - the dialog titlemessage - the text to display above the listdescription - an optional text descriptioncontents - an AbstractListModel, JList, Vector, Enumeration or Iterator containing list contentsselectionMode - a value of JList's selection moderenderer - an optional cell rendererinitVisible - when true, displays the dialog upon instantiation| Method Detail |
|---|
protected JPanel createNorthPanel(String message)
public void setListTitle(String title,
String message)
protected JPanel createCenterPanel(int selectionMode,
String description)
public void setContents(Object o)
protected void setSelectedButton(int value)
public int getSelectedButton()
public JButton getExtraButton()
public void setSelected(Object o)
public void setActive(boolean active)
public void removeAllButton()
public void removeNoneButton()
protected JPanel createSouthPanel(int selectionMode,
boolean includeHelp)
protected void addNavigationButtons(JPanel panel)
public boolean isHelpVisible()
public void setHelpText(String content)
public Object getSelectedValue()
public Collection getSelectedValues()
public int[] getSelectedIndices()
public Collection getSelection()
String result = (String)dialog.getSelection().firstElement();
I.e., if the supplied values were Strings, and after first checking
that the result is non-null.
public int getSelectedCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||