com.quadrique.jbuildingblocks.gui
Class Dlg

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by com.quadrique.jbuildingblocks.gui.Dlg
All Implemented Interfaces:
ButtonAreaListener, ComponentListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
DlgAbout, DlgDateChooser, DlgException, DlgInformation, DlgLabelTextField, DlgLogin, DlgQuestion, PanelListBaseDlg, Wizard

public class Dlg
extends JDialog
implements WindowListener, ComponentListener, ButtonAreaListener

This class is the base class for all the dialogs of the application. It provides all the common services as well as a consistent look&feel and behavior. Each dialog has an optional icon panel (west), a center panel and a button area. When a dialog window is opened, it is positioned at the golden mean of the parent window (a point directly on the parent's vertical midline and slightly above its horizontal midline). When a dialog window is opened, a specialized method (assignFocus()) is called so that you assign the initial focus to a specific component. Each dialog window can be resized but its dimension cannot be smaller than the minimum size for the components. If a dialog windows is closed, the returned value is set to -1

Author:
Hervé Rivere
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.ModalExclusionType, Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
static int RETURN_VALUE_IS_DLG_WINDOW_CLOSED
          constants
 
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
Dlg(Component zParentComponent, String zTitle, String zIconName, boolean zIsModal)
          constructor
Dlg(Dialog zParentDialog, String zTitle, String zIconName, boolean zIsModal)
          use this constructor whenever the dialog is dispayed from a modal dialog.
 
Method Summary
 JButton addButton(ActionBase zAction, boolean zCloseDialogIfActivated, boolean zIsDefault)
          buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)
 JButton addButton(String zLabel, String zTooltip, int zMnemonic, boolean zCloseDialogIfActivated, boolean zIsDefault)
          buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)
 void addCenterComponent(JComponent zComponent, JComponent zComponentWithInitialFocus)
          Adds the component to the "center" area of the dialog Please note that the Java Look&Feel recommended border is automatically added to the component.
 void addEmptySpaceInButtonArea(int zNbOfPixels)
          add a fixed size empty space to the panel (e.g.
 void addHelpButton(String zLabel, String zTooltip, int zMnemonic, String zHelpKey)
          buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)
 void buttonSelected(ButtonAreaEvent zEvent)
          This method is called whenever one of the buttons is called
 void closeDialog(int zReturnValue)
          to terminate the execution of the dialog
 void componentHidden(ComponentEvent zEvent)
           
 void componentMoved(ComponentEvent e)
           
 void componentResized(ComponentEvent e)
           
 void componentShown(ComponentEvent e)
           
 ButtonArea getButtonArea()
           
static Dialog getDialog(Component zComponent)
           
 int getReturnValue()
          This method returns the dialog return value.
 void setButtonAreaIsVisible(boolean zIsVisible)
           
 void windowActivated(WindowEvent zEvent)
           
 void windowClosed(WindowEvent zEvent)
           
 void windowClosing(WindowEvent zEvent)
           
 void windowDeactivated(WindowEvent zEvent)
           
 void windowDeiconified(WindowEvent zEvent)
           
 void windowIconified(WindowEvent zEvent)
           
 void windowOpened(WindowEvent zEvent)
           
 
Methods inherited from class javax.swing.JDialog
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
 
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.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RETURN_VALUE_IS_DLG_WINDOW_CLOSED

public static final int RETURN_VALUE_IS_DLG_WINDOW_CLOSED
constants

See Also:
Constant Field Values
Constructor Detail

Dlg

public Dlg(Component zParentComponent,
           String zTitle,
           String zIconName,
           boolean zIsModal)
constructor

Parameters:
zParentComponent - the parent component that will be used to position the dialog
zTitle - the title of the dialog
zIconName - the name of the icon. use null if no icon is needed
zIsModal - true if the dialog is modal

Dlg

public Dlg(Dialog zParentDialog,
           String zTitle,
           String zIconName,
           boolean zIsModal)
use this constructor whenever the dialog is dispayed from a modal dialog. Please note that you can use the static method Dlg.getDialog) to retrieve the parent dialog

Parameters:
zParentDialog -
zTitle -
zIconName -
zIsModal -
Method Detail

getDialog

public static Dialog getDialog(Component zComponent)
Parameters:
zComponent - the parent component that will be used to position the dialog
Returns:
the parent Dialog instance if any

addCenterComponent

public void addCenterComponent(JComponent zComponent,
                               JComponent zComponentWithInitialFocus)
Adds the component to the "center" area of the dialog Please note that the Java Look&Feel recommended border is automatically added to the component.

Parameters:
zComponent - the component to add
zComponentWithInitialFocus - the component in the component (if any) who should have the focus

addButton

public JButton addButton(String zLabel,
                         String zTooltip,
                         int zMnemonic,
                         boolean zCloseDialogIfActivated,
                         boolean zIsDefault)
buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)

Parameters:
zLabel - the name of the button
zTooltip - the text for the tooltip
zMnemonic - the menmonic for the button (e.g. KeyEvent.VK_P or KeyEvent.VK_UNDEFINED)
zCloseDialogIfActivated - if ture, the dialog is closed when the action is activated
zIsDefault - true if this is the default button
Returns:
the newly created button

addButton

public JButton addButton(ActionBase zAction,
                         boolean zCloseDialogIfActivated,
                         boolean zIsDefault)
buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)

Parameters:
zAction - the action to use
zCloseDialogIfActivated - if ture, the dialog is closed when the action is activated
zIsDefault - true if this is the default button
Returns:
the newly created button

addHelpButton

public void addHelpButton(String zLabel,
                          String zTooltip,
                          int zMnemonic,
                          String zHelpKey)
buttons are added from o to n-1 ==> return value contains the button id (0 to n-1)

Parameters:
zLabel - the name of the button
zTooltip - the text for the tooltip
zMnemonic - the menmonic for the button (e.g. KeyEvent.VK_P or KeyEvent.VK_UNDEFINED)
zHelpKey - the key of the corresponding section in the online HelpSet file

addEmptySpaceInButtonArea

public void addEmptySpaceInButtonArea(int zNbOfPixels)
add a fixed size empty space to the panel (e.g. in a wizard, you need to separate a set of buttons from the others)

Parameters:
zNbOfPixels - the number of pixels

setButtonAreaIsVisible

public void setButtonAreaIsVisible(boolean zIsVisible)

getReturnValue

public int getReturnValue()
This method returns the dialog return value.

Returns:
RETURN_VALUE_IS_DLG_WINDOW_CLOSED when the user closes the window from the title bar, another numeric value (specific to each derived class) otherwise.

windowClosing

public void windowClosing(WindowEvent zEvent)
Specified by:
windowClosing in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowActivated

public void windowActivated(WindowEvent zEvent)
Specified by:
windowActivated in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowDeactivated

public void windowDeactivated(WindowEvent zEvent)
Specified by:
windowDeactivated in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowIconified

public void windowIconified(WindowEvent zEvent)
Specified by:
windowIconified in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowDeiconified

public void windowDeiconified(WindowEvent zEvent)
Specified by:
windowDeiconified in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowClosed

public void windowClosed(WindowEvent zEvent)
Specified by:
windowClosed in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

windowOpened

public void windowOpened(WindowEvent zEvent)
Specified by:
windowOpened in interface WindowListener
Parameters:
zEvent - the event
See Also:
WindowListener

componentHidden

public void componentHidden(ComponentEvent zEvent)
Specified by:
componentHidden in interface ComponentListener
Parameters:
zEvent - the event
See Also:
ComponentListener

componentShown

public void componentShown(ComponentEvent e)
Specified by:
componentShown in interface ComponentListener
Parameters:
e - the event
See Also:
ComponentListener

componentMoved

public void componentMoved(ComponentEvent e)
Specified by:
componentMoved in interface ComponentListener
Parameters:
e - the event
See Also:
ComponentListener

componentResized

public void componentResized(ComponentEvent e)
Specified by:
componentResized in interface ComponentListener
Parameters:
e - the event
See Also:
ComponentListener

buttonSelected

public void buttonSelected(ButtonAreaEvent zEvent)
This method is called whenever one of the buttons is called

Specified by:
buttonSelected in interface ButtonAreaListener
Parameters:
zEvent - the event
See Also:
ButtonArea, ButtonAreaEvent

closeDialog

public void closeDialog(int zReturnValue)
to terminate the execution of the dialog

Parameters:
zReturnValue - to set the return value to the desired value

getButtonArea

public ButtonArea getButtonArea()
Returns:
the button area


Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.