|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
info.aduna.swing.DialogTemplate
public class DialogTemplate
A template that can be used to construct dialogs. Such a dialog will look like this:
| Title | |
| icon | message |
| buttons | |
Any number of buttons can be added to the dialog, they are layed out from left to right in the order they were added. A button must be of class JButton or of some subclass of JButton. Buttons don't automatically close the dialog, this can be set when a button is added.
As the dialog's components are layed out on the DialogTemplate itself and since that is a JPanel, changing display properties of the DialogTemplate will also effect the dialog (e.g. changing the background color will result in a dialog with that background color).
This implementation is a redo of the JOptionPane because that implementation is far too restrictive.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| 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 |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
DialogTemplate()
Creates a new non-modal DialogTemplate. |
|
DialogTemplate(JComponent message)
Creates a new non-modal DialogTemplate that will display the supplied message. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(ActionEvent e)
DialogTemplate listens to ActionEvents from buttons that should hide the dialog. |
JButton |
addButton(Icon icon,
boolean hidesDialog)
Adds a JButton with a certain icon on it to the dialog. |
JButton |
addButton(JButton button,
boolean hidesDialog)
Adds a JButton to the dialog. |
JButton |
addButton(String label,
boolean hidesDialog)
Adds a JButton with a certain label to the dialog. |
void |
addWindowListener(WindowListener listener)
|
void |
disposeDialog()
Gets rid of the dialog. |
JButton |
getClickedButton()
Gets the button that caused the dialog to hide. |
void |
hideDialog()
Hides the dialog. |
void |
makeModalOn(Window owner)
Makes the dialog modal on the supplied owner. |
void |
makeNonModal()
Makes the dialog non-modal. |
void |
removeWindowListener(WindowListener listener)
|
void |
setDefaultButton(JButton button)
Sets the default button of the dialog. |
void |
setIcon(Icon icon)
Sets the icon to display on the dialog. |
void |
setMessage(JComponent message)
Sets the "message" for the dialog. |
void |
setParent(Component parent)
Sets the 'parent' of the dialog. |
void |
setTitle(String title)
Sets the title for the dialog. |
void |
showDialog()
Shows the dialog. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DialogTemplate()
public DialogTemplate(JComponent message)
message - The message to display| Method Detail |
|---|
public void setMessage(JComponent message)
message - The (new) messagepublic void setIcon(Icon icon)
icon - The icon to display
public JButton addButton(String label,
boolean hidesDialog)
label - The label for the buttonhidesDialog - Flag indicating whether a click on the button should hide the
dialog
public JButton addButton(Icon icon,
boolean hidesDialog)
icon - The icon for the buttonhidesDialog - Flag indicating whether a click on the button should hide the
dialog
public JButton addButton(JButton button,
boolean hidesDialog)
button - The button to addhidesDialog - Flag indicating whether a click on the button should hide the
dialog
public JButton getClickedButton()
public void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenerpublic void setDefaultButton(JButton button)
public void setTitle(String title)
title - The (new) titlepublic void makeModalOn(Window owner)
owner - The 'owner' of the dialog
IllegalArgumentException - If 'owner' is not a (subclass of) Frame or Dialog, or if it is
equal to 'null'.public void makeNonModal()
public void setParent(Component parent)
parent - The (new) parent of the component, or null if no parent should be
setpublic void addWindowListener(WindowListener listener)
public void removeWindowListener(WindowListener listener)
public void showDialog()
public void hideDialog()
public void disposeDialog()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||