|
||||||||||
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
edu.rice.cs.util.swing.ScrollableListSelectionDialog
public class ScrollableListSelectionDialog
The ScrollableListSelectionDialog is a popup dialog with a message and a scrollable list of items. Each item may be either selected or unselected. A ScrollableListSelectionDialog should be used when an operation needs to act on a variable number of items, for example, when saving modified files.
The message (also know as the leader text) is displayed above the items with an optional icon. The items are displayed in a scrollable table. A column of checkboxes allows selection of the items. Buttons are added below the list of items.
This dialog is somewhat styled after
JOptionPane
and uses the message-type constants
from JOptionPane.
Nested Class Summary | |
---|---|
static class |
ScrollableListSelectionDialog.SelectionState
A enumeration of the various selection states. |
Nested classes/interfaces inherited from class javax.swing.JDialog |
---|
JDialog.AccessibleJDialog |
Nested classes/interfaces inherited from class java.awt.Dialog |
---|
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType |
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Vector<String> |
dataAsStrings
The items in the table. |
protected Vector<Boolean> |
selectedItems
The selected items in the table. |
protected JTable |
table
The table displaying the items. |
protected AbstractTableModel |
tableModel
The AbstractTableModel backing the table. |
Fields inherited from class javax.swing.JDialog |
---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Dialog |
---|
DEFAULT_MODALITY_TYPE |
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 | |
---|---|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription)
Creates a new ScrollableListSelectionDialog with the given title, leader text, and items. |
|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, and message type. |
|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType,
int width,
int height,
Icon icon)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. |
Method Summary | |
---|---|
protected void |
_addButtons(JPanel buttonPanel)
Adds buttons to the bottom of the dialog. |
protected void |
closeDialog()
Should be called when the dialog should be closed. |
static void |
main(String[] args)
A simple main method for testing purposes. |
List<String> |
selectedItems()
Returns the string representation of those items that are currently selected. |
void |
showDialog()
Shows the dialog. |
Methods inherited from class java.awt.Dialog |
---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final JTable table
protected final AbstractTableModel tableModel
protected final Vector<String> dataAsStrings
protected final Vector<Boolean> selectedItems
Constructor Detail |
---|
public ScrollableListSelectionDialog(Frame owner, String dialogTitle, String leaderText, Collection<?> listItems, String itemDescription)
Creates a new ScrollableListSelectionDialog with the given title, leader text, and items. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The default sizing, message type, and icon are used. All the items are selected by default.
owner
- The frame that owns this dialog. May be null
.dialogTitle
- The text to use as the dialog title.leaderText
- Text to display before the list of items.listItems
- The items to display in the list.itemDescription
- A textual description of the items. This is used as the column heading for the items.
IllegalArgumentException
- if listItems
is null.
public ScrollableListSelectionDialog(Frame owner, String dialogTitle, String leaderText, Collection<?> listItems, String itemDescription, ScrollableListSelectionDialog.SelectionState defaultSelection, int messageType)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, and message type. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The message type must be one of the message types from
JOptionPane
. The message type controlls which
default icon is used.
The default sizing and icon are used.
owner
- The frame that owns this dialog. May be null
.dialogTitle
- The text to use as the dialog title.leaderText
- Text to display before the list of items.listItems
- The items to display in the list.itemDescription
- A textual description of the items. This is used as the column heading for the items.defaultSelection
- The default selection state (selected or unselected) for the items.messageType
- The type of dialog message.
IllegalArgumentException
- if listItems
is null.
IllegalArgumentException
- if the message type is unknown or listItems
is null.
public ScrollableListSelectionDialog(Frame owner, String dialogTitle, String leaderText, Collection<?> listItems, String itemDescription, ScrollableListSelectionDialog.SelectionState defaultSelection, int messageType, int width, int height, Icon icon)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The message type must be one of the message types from
JOptionPane
. The message type controlls which
default icon is used. If icon
is non-null, it is used
instead of the default icon.
owner
- The frame that owns this dialog. May be null
.dialogTitle
- The text to use as the dialog title.leaderText
- Text to display before the list of items.listItems
- The items to display in the list.itemDescription
- A textual description of the items. This is used as the column heading for the items.defaultSelection
- The default selection state (selected or unselected) for the items.messageType
- The type of dialog message.width
- The width of the dialog box.height
- The height of the dialog box.icon
- The icon to display. May be null
.
IllegalArgumentException
- if listItems
is null.
IllegalArgumentException
- if the message type is unknown or listItems
is null.
Method Detail |
---|
protected void _addButtons(JPanel buttonPanel)
closeDialog()
. It
is also set as the dialog's default button.
Inheritors should feel free the change settings of the panel such
as the layout manager. However, no guarantees are made that every
change will work with every version of this class.
buttonPanel
- The JPanel that should contain the buttons.public void showDialog()
protected void closeDialog()
public List<String> selectedItems()
public static void main(String[] args)
args
- Not used.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |