|
||||||||||
| 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.ScrollableListDialog<T>
public class ScrollableListDialog<T>
The ScrollableListDialog is a popup dialog with a message and a scrollable list of items. A ScrollableListDialog should be used when a message may need to display a variable number of items, for example, when reporting missing 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 list. 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 |
ScrollableListDialog.Builder<T>
Factory design pattern. |
| 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 int |
_buttonPressed
The number of the button that was pressed to close the dialog. |
private static int |
DEFAULT_HEIGHT
The default height for this dialog. |
private static int |
DEFAULT_WIDTH
The default width for this dialog. |
private static double |
HEIGHT_RATIO
The ratio of the screen height to use by default. |
protected |
list
The list of items displayed. |
protected List<T> |
listItems
The list of items being listed. |
private static double |
WIDTH_RATIO
The ratio of the screen width to use by default. |
| 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 | |
|---|---|
private |
ScrollableListDialog(Frame owner,
String dialogTitle,
String leaderText,
List<T> listItems,
List<T> selItems,
int messageType,
int width,
int height,
Icon icon,
boolean fitToScreen,
List<JButton> buttons,
List<JComponent> additional,
boolean selectable)
Creates a new ScrollableListDialog with the given title, leader text, items, message type, width, height, and icon. |
| Method Summary | |
|---|---|
protected void |
_addAdditionalComponents(JPanel buttonPanel,
List<JComponent> additional)
Adds additional components to the bottom of the dialog. |
protected void |
_addButtons(JPanel buttonPanel,
List<JButton> buttons)
Adds buttons to the bottom of the dialog. |
private Icon |
_getIcon(int messageType)
Lookup the icon associated with the given messageType. |
private boolean |
_isknownMessageType(int messageType)
A method to check if they given message type is a know message type. |
protected void |
closeDialog()
Should be called when the dialog should be closed. |
int |
getButtonPressed()
Return the number of the button that was pressed to close the dialog. |
List<T> |
getSelectedItems()
Return a list of the selected items. |
static void |
main(String[] args)
A simple main method for testing purposes. |
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 |
|---|
private static final int DEFAULT_WIDTH
private static final int DEFAULT_HEIGHT
private static final double WIDTH_RATIO
private static final double HEIGHT_RATIO
protected finallist
protected int _buttonPressed
protected List<T> listItems
| Constructor Detail |
|---|
private ScrollableListDialog(Frame owner,
String dialogTitle,
String leaderText,
List<T> listItems,
List<T> selItems,
int messageType,
int width,
int height,
Icon icon,
boolean fitToScreen,
List<JButton> buttons,
List<JComponent> additional,
boolean selectable)
Creates a new ScrollableListDialog 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.selItems - The items selected at the beginning.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.fitToScreen - If true, the width and height of the dialog will be calculated using the screen
dimensions, WIDTH_RATIO, and HEIGHT_RATIO. If false, the provided width and
height will be used.buttons - The list of buttons to displayadditional - The list of additional components to displayselectable - true if items can be selected
IllegalArgumentException - if listItems is null.
IllegalArgumentException - if the message type is unknown or listItems is null.| Method Detail |
|---|
private boolean _isknownMessageType(int messageType)
messageType - The message type to check
true if the message type is known, false otherwiseprivate Icon _getIcon(int messageType)
JOptionPane.
messageType - The message for which the icon is requested.
null is no icon was found.
protected void _addButtons(JPanel buttonPanel,
List<JButton> buttons)
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.buttons - The list of buttons
protected void _addAdditionalComponents(JPanel buttonPanel,
List<JComponent> additional)
buttonPanel - The JPanel that should contain the components.additional - The list of componentspublic void showDialog()
protected void closeDialog()
public int getButtonPressed()
public List<T> getSelectedItems()
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 | |||||||||