|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Dialog | +--javax.swing.JDialog | +--de.qfs.lib.gui.ModalDialog
This is a very useful base class for modal dialogs that display one large component - or several components grouped into a large one - above a row of buttons. ModalDialog reads the number and labels of the buttons as well as some of their characteristics from a set of resources, simplifying localization together with layout, default actions, and return value definition.
The following resources are used by default. These may be extended or ignored by derived classes.
Resource name | Usage |
---|---|
Dialog resources | |
dialog.name.title |
The title of the dialog (optional, no default). |
dialog.name.name |
The name of the dialog (optional, default
ModalDialog-name ). |
dialog.name.width |
The minimum width of the dialog (optional, no default). |
dialog.name.height |
The minimum height of the dialog (optional, no default). |
dialog.name.configure |
If true, create a ConfigWrapper for the dialog and register it under the name
name.dialog (optional, default false). |
dialog.name.buttons |
The resource names of the buttons for the dialog (optional, default
"ok cancel" ). |
Button resources | |
dialog.button.name.label |
The label of the button (required). |
dialog.button.name.mnemonic |
Keyboard accelerator (optional, default none). |
dialog.button.name.name |
The name of the button set with setName (optional, default "Button-name" ). |
dialog.button.name.close |
Whether to close the dialog when the button is pressed (optional, default true). |
dialog.button.name.retval |
The return value for doModal when the dialog is closed
via this button. Ignored unless close is true (optional,
default is the index of the button, starting from 0) . |
dialog.button.name.default |
Whether the button is default capable. The first button with
default set to true will be the initial default button
(optional, default false) . |
dialog.button.name.disabled |
If true, the button will be disabled (optional, default false) . |
Default values for the buttons ok
, yes
,
no
and cancel
are defined in the resource bundle
/de/qfs/lib/resources/properties/qflib
in
qflib.jar
. You should include these in the resources you pass
to init
.
Inner Class Summary | |
static class |
ModalDialog.ButtonData
A structure that encapsulates the values for a button. |
Inner classes inherited from class javax.swing.JDialog |
javax.swing.JDialog.AccessibleJDialog |
Inner classes inherited from class java.awt.Dialog |
java.awt.Dialog.AccessibleAWTDialog |
Inner classes inherited from class java.awt.Window |
java.awt.Window.AccessibleAWTWindow |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
protected ModalDialog.ButtonData[] |
buttons
Data for the buttons of the dialog. |
static int |
CANCEL_OPTION
Return value for the cancel button. |
static int |
CLOSED_OPTION
Retun value when the dialog is closed. |
protected static java.lang.String[] |
defaultButtons
The default button names. |
protected java.awt.GridBagLayout |
layout
The layout for the dialog. |
protected java.awt.Component |
mainComponent
The main component of the dialog. |
protected javax.swing.JPanel |
mainPanel
The panel for the main component. |
protected int |
minHeight
The minimum height of the dialog. |
protected int |
minWidth
The minimum width of the dialog. |
protected java.lang.String |
name
The resource name of the dialog. |
static int |
NO_OPTION
Return value for the no button. |
static int |
OK_OPTION
Return value for the ok button. |
protected javax.swing.JPanel |
panel
The content pane of the dialog. |
protected int |
retval
The return code from the last call to doModal . |
static int |
YES_OPTION
Return value for the yes button. |
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, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
ModalDialog(java.lang.String name,
java.awt.Dialog parent)
Create a new ModalDialog. |
|
ModalDialog(java.lang.String name,
java.awt.Dialog parent,
java.awt.Component com)
Create a new ModalDialog. |
|
ModalDialog(java.lang.String name,
java.awt.Frame parent)
Create a new ModalDialog. |
|
ModalDialog(java.lang.String name,
java.awt.Frame parent,
java.awt.Component com)
Create a new ModalDialog. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Handler for a button press. |
static java.lang.String |
buttonResName(java.lang.String button,
java.lang.String res)
Helper method that uses a StringBuffer to build a resource name for one of the dialog's buttons. |
int |
doModal(java.awt.Component parent,
boolean resetFocus)
Bring up the dialog and wait for the user to finish editing. |
protected int |
findButton(javax.swing.JButton button)
Get the index of a button. |
protected void |
fixSize()
Pack the dialog and enlarge it if necessary for the minimum width and height. |
javax.swing.JButton |
getButton(int index)
Get a button of the dialog. |
javax.swing.JButton |
getButton(java.lang.String name)
Get a button of the dialog. |
int |
getButtonCount()
Get the number of buttons of the dialog. |
void |
init(MapResourceBundle rb)
Initialize the dialog and the buttons. |
protected ModalDialog.ButtonData |
initButton(java.lang.String bname,
MapResourceBundle rb)
Initialize one button. |
protected java.lang.String[] |
initButtonNames(MapResourceBundle rb)
Get the names of the dialog's buttons. |
protected void |
initComponent()
This method can be overridden in a derived class to initialize the mainComponent member of the dialog. |
java.lang.String |
resName(java.lang.String res)
Helper method that uses a StringBuffer to build a resource name for the dialog. |
void |
setMainComponent(java.awt.Component com)
Set the main component of the dialog. |
void |
windowActivated(java.awt.event.WindowEvent e)
Noop. |
void |
windowClosed(java.awt.event.WindowEvent e)
Noop. |
void |
windowClosing(java.awt.event.WindowEvent e)
Cancellation handler. |
void |
windowDeactivated(java.awt.event.WindowEvent e)
Noop. |
void |
windowDeiconified(java.awt.event.WindowEvent e)
Noop. |
void |
windowIconified(java.awt.event.WindowEvent e)
Noop. |
void |
windowOpened(java.awt.event.WindowEvent e)
Noop. |
Methods inherited from class javax.swing.JDialog |
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setLocationRelativeTo, setRootPane, setRootPaneCheckingEnabled, update |
Methods inherited from class java.awt.Dialog |
addNotify, dispose, getTitle, hide, isModal, isResizable, setModal, setResizable, setTitle, show |
Methods inherited from class java.awt.Window |
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, toBack, toFront |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CLOSED_OPTION
public static final int OK_OPTION
public static final int YES_OPTION
public static final int NO_OPTION
public static final int CANCEL_OPTION
protected static final java.lang.String[] defaultButtons
protected java.lang.String name
protected int retval
doModal
.protected java.awt.Component mainComponent
protected javax.swing.JPanel mainPanel
protected ModalDialog.ButtonData[] buttons
protected java.awt.GridBagLayout layout
protected javax.swing.JPanel panel
protected int minWidth
protected int minHeight
Constructor Detail |
public ModalDialog(java.lang.String name, java.awt.Frame parent)
init
afterwards.name
- The resource name of the dialog.parent
- The dialog's owner.public ModalDialog(java.lang.String name, java.awt.Frame parent, java.awt.Component com)
init
afterwards.name
- The resource name of the dialog.parent
- The dialog's owner.com
- The main component for the dialog.public ModalDialog(java.lang.String name, java.awt.Dialog parent)
init
afterwards.name
- The resource name of the dialog.parent
- The dialog's owner.public ModalDialog(java.lang.String name, java.awt.Dialog parent, java.awt.Component com)
init
afterwards.name
- The resource name of the dialog.parent
- The dialog's owner.com
- The main component for the dialog.Method Detail |
public void init(MapResourceBundle rb)
rb
- The resources to use.public void setMainComponent(java.awt.Component com)
com
- The new main component.public int doModal(java.awt.Component parent, boolean resetFocus)
parent
- Place the dialog relative to this component if
non-null.resetFocus
- Whether to reset the focus to the first child
component of the dialog.public int getButtonCount()
public javax.swing.JButton getButton(int index) throws java.lang.IndexOutOfBoundsException
index
- The index of the button.java.lang.IndexOutOfBoundsException
- If there is no button for that index.public javax.swing.JButton getButton(java.lang.String name)
name
- The resource name of the button.protected java.lang.String[] initButtonNames(MapResourceBundle rb)
rb
- The resources to use.protected ModalDialog.ButtonData initButton(java.lang.String bname, MapResourceBundle rb)
bname
- The resource name of the button.rb
- The resources to use.protected void initComponent()
mainComponent
member of the dialog. It will be
placed a small distance above the buttons, filling all the remaining
space.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- The event containing the details.public void windowClosing(java.awt.event.WindowEvent e)
windowClosing
in interface java.awt.event.WindowListener
e
- The event containing the details.public void windowOpened(java.awt.event.WindowEvent e)
windowOpened
in interface java.awt.event.WindowListener
public void windowClosed(java.awt.event.WindowEvent e)
windowClosed
in interface java.awt.event.WindowListener
public void windowActivated(java.awt.event.WindowEvent e)
windowActivated
in interface java.awt.event.WindowListener
public void windowDeactivated(java.awt.event.WindowEvent e)
windowDeactivated
in interface java.awt.event.WindowListener
public void windowIconified(java.awt.event.WindowEvent e)
windowIconified
in interface java.awt.event.WindowListener
public void windowDeiconified(java.awt.event.WindowEvent e)
windowDeiconified
in interface java.awt.event.WindowListener
protected void fixSize()
public java.lang.String resName(java.lang.String res)
res
- The resource needed.public static java.lang.String buttonResName(java.lang.String button, java.lang.String res)
button
- The resource name of the button.res
- The resource needed.protected int findButton(javax.swing.JButton button)
button
- The button to look for.
|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |