[.home.]
[.hacks.]
[.java.]

Class DialogBox

java.lang.Object
  |
  +--DialogBox
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.WindowListener

public class DialogBox
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.WindowListener

(#)DialogBox.java

Version:
3.2 19-Mar-2004

A Wrapper arount the AWT Dialog class. Standard dialogs are supplied as static member functions. Can be used without specifying a parent frame (creates its own parent) Attention: Dialog crashes on some Netscape 4.7x Version on Solaris in combination with LANG=en_US (or != C) and Dialog contains a TextField/TextArea (Problem is related to XInputMethods)
Author:
Holger Pfaff

Field Summary
static java.awt.Image Bsy
          busy image for standard dialogboxes
static java.lang.String CANCEL
          Cancel string for standard dialogboxes (no i18n)
static java.awt.Image Err
          error image for standard dialogboxes
static java.lang.String ERR
          Error string for standard dialogboxes (no i18n)
static java.awt.Image Inf
          info image for standard dialogboxes
static java.lang.String INF
          Info string for standard dialogboxes (no i18n)
static java.lang.String OK
          OK string for standard dialogboxes (no i18n)
static java.awt.Image Wrn
          warning image for standard dialogboxes
static java.lang.String WRN
          Warning string for standard dialogboxes (no i18n)
 
Constructor Summary
DialogBox()
          Construct a new Dialog.
DialogBox(java.awt.Panel p, java.lang.String t, java.lang.String b)
          Construct a new Dialog.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Implement the Action listener interface.
 void addActionListener(java.awt.event.ActionListener l)
          Add ActionListener to this dialog
 void addButton(java.lang.String l)
          Add a dialog button to this box.
 void addButton(java.lang.String l, java.lang.String c)
          Add a dialog button to this box.
 void addButtons(java.lang.String l)
          Add a dialog buttons to this box.
static DialogBox busyDialog(java.lang.String msg)
          Static utility method to create a standard busy dialog.
 void dispose(java.lang.Object retCode)
          Destroys this dialog
static DialogBox errorDialog(java.lang.String msg)
          Static utility method to create a standard error dialog
 Knob getButton(int i)
          Get the button object for a specific dialog button.
 java.lang.String getCloseWindowCommand()
          Get the close window command of this dialog.
 java.awt.Frame getFrame()
          Get parent frame.
 java.awt.Panel getPanel()
          Get the main panel (content of this dialog).
 java.awt.Frame getParent()
          Get parent frame.
 boolean getResizable()
          Dialog resizeable ?
 java.lang.String getTitle()
          Get the title of this dialog.
static DialogBox infoDialog(java.lang.String msg)
          Static utility method to create a standard info dialog.
 boolean isModal()
          Get the modal behavior of this dialog.
 boolean isShowing()
          Dialog on screen ?
 void notifyActionListeners(int but)
          Notify all ActionListener
 void pack()
          Make it nice looking
 void removeActionListener(java.awt.event.ActionListener l)
          Remove ActionListener to this dialog
 void removeActionListeners()
          Remove all ActionListener
 void setButtonAction(int i, java.lang.String a)
          Utility method to change the action string for a dialog button.
 void setButtonEnabled(int i, boolean e)
          Utility method to en-/disable a dialog button.
 void setCloseWindowCommand(java.lang.String c)
          Set the close window command of this dialog.
 void setModal(boolean m)
          Set the modal behavior of this dialog.
 void setPanel(java.awt.Panel p)
          Set the main panel (content of this dialog).
 void setParent(java.awt.Component c)
          Set parent.
 void setResizable(boolean r)
          Set if Dialog is resizeable
 void setTitle(java.lang.String t)
          Set the title of this dialog.
 java.lang.Object show()
          Shows this dialog.
 java.lang.Object show(boolean bep)
          Shows this dialog.
 java.lang.Object show(java.awt.Component p)
          Shows this dialog.
 java.lang.Object show(java.awt.Component p, boolean bep)
          Shows this dialog.
static DialogBox standardDialog(java.lang.String tit, java.lang.String msg, java.lang.String but, java.awt.Image img)
          Static utility method to create a standard Dialog with optional image
static DialogBox warnDialog(java.lang.String msg)
          Static utility method to create a standard warning dialog.
 void windowActivated(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowClosed(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowClosing(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowDeactivated(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowDeiconified(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowIconified(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 void windowOpened(java.awt.event.WindowEvent e)
          Implement the Window listener interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Err

public static final java.awt.Image Err
error image for standard dialogboxes


Wrn

public static final java.awt.Image Wrn
warning image for standard dialogboxes


Inf

public static final java.awt.Image Inf
info image for standard dialogboxes


Bsy

public static final java.awt.Image Bsy
busy image for standard dialogboxes


OK

public static final java.lang.String OK
OK string for standard dialogboxes (no i18n)

See Also:
Constant Field Values

CANCEL

public static final java.lang.String CANCEL
Cancel string for standard dialogboxes (no i18n)

See Also:
Constant Field Values

ERR

public static final java.lang.String ERR
Error string for standard dialogboxes (no i18n)

See Also:
Constant Field Values

WRN

public static final java.lang.String WRN
Warning string for standard dialogboxes (no i18n)

See Also:
Constant Field Values

INF

public static final java.lang.String INF
Info string for standard dialogboxes (no i18n)

See Also:
Constant Field Values
Constructor Detail

DialogBox

public DialogBox(java.awt.Panel p,
                 java.lang.String t,
                 java.lang.String b)
Construct a new Dialog.

Parameters:
p - the content of this dialog.
t - title for dialog frame (window manager).
b - comma separated list of buttons.

DialogBox

public DialogBox()
Construct a new Dialog. This empty contructor is intended for custom dialogs. Use setPanel and addButtons to make this DialogBox useable.

Method Detail

getFrame

public java.awt.Frame getFrame()
Get parent frame.


getParent

public java.awt.Frame getParent()
Get parent frame.


setParent

public void setParent(java.awt.Component c)
Set parent.

Parameters:
c - use this components parent frame.

getPanel

public java.awt.Panel getPanel()
Get the main panel (content of this dialog).


setPanel

public void setPanel(java.awt.Panel p)
Set the main panel (content of this dialog).

Parameters:
p - use this panel for the dialogbox's content.

getTitle

public java.lang.String getTitle()
Get the title of this dialog.


setTitle

public void setTitle(java.lang.String t)
Set the title of this dialog. Has no effect after show()


isModal

public boolean isModal()
Get the modal behavior of this dialog.


setModal

public void setModal(boolean m)
Set the modal behavior of this dialog.

Parameters:
m - blocking or not ?

isShowing

public boolean isShowing()
Dialog on screen ?


setResizable

public void setResizable(boolean r)
Set if Dialog is resizeable

Parameters:
r - resizeable or not ?

getResizable

public boolean getResizable()
Dialog resizeable ?


addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Add ActionListener to this dialog

Parameters:
l - ActionListener to add

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Remove ActionListener to this dialog

Parameters:
l - ActionListener to remove

removeActionListeners

public void removeActionListeners()
Remove all ActionListener


notifyActionListeners

public void notifyActionListeners(int but)
Notify all ActionListener

Parameters:
but - Index of button that was pressed

getCloseWindowCommand

public java.lang.String getCloseWindowCommand()
Get the close window command of this dialog.


setCloseWindowCommand

public void setCloseWindowCommand(java.lang.String c)
Set the close window command of this dialog. The action with this string causes the dialog to disappear. Default null means close on any dialog button

Parameters:
c - the closing string

addButton

public void addButton(java.lang.String l,
                      java.lang.String c)
Add a dialog button to this box.

Parameters:
l - the label to show
c - the action command for this button. See setCloseWindowCommand.

addButton

public void addButton(java.lang.String l)
Add a dialog button to this box. Label = action command

Parameters:
l - the label and action command

addButtons

public void addButtons(java.lang.String l)
Add a dialog buttons to this box. Label = action command

Parameters:
l - comma separated list of labels and action commands

getButton

public Knob getButton(int i)
Get the button object for a specific dialog button. The index depends on the order the buttons were added.

Parameters:
i - which button ?

setButtonEnabled

public void setButtonEnabled(int i,
                             boolean e)
Utility method to en-/disable a dialog button.

Parameters:
i - which button ?
e - active ?

setButtonAction

public void setButtonAction(int i,
                            java.lang.String a)
Utility method to change the action string for a dialog button.

Parameters:
i - which button ?
a - new action

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Implement the Action listener interface. Dispose this dialog depending on closeWindowCommand.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Implement the Window listener interface. Dispose this dialog depending on event and closeWindowCommand.

Specified by:
windowClosing in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Implement the Window listener interface. Dispose this dialog depending on event and closeWindowCommand.

Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Implement the Window listener interface.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Implement the Window listener interface.

Specified by:
windowOpened in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Implement the Window listener interface.

Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Implement the Window listener interface.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Implement the Window listener interface.

Specified by:
windowClosed in interface java.awt.event.WindowListener

show

public java.lang.Object show()
Shows this dialog. Block if dialog is modal.


show

public java.lang.Object show(boolean bep)
Shows this dialog. Block if dialog is modal.

Parameters:
bep - seems handy for error dialogs.

show

public java.lang.Object show(java.awt.Component p)
Shows this dialog. Block if dialog is modal.

Parameters:
p - use this components parent frame.

show

public java.lang.Object show(java.awt.Component p,
                             boolean bep)
Shows this dialog. Block if dialog is modal.


pack

public void pack()
Make it nice looking


dispose

public void dispose(java.lang.Object retCode)
Destroys this dialog

Parameters:
retCode - return this to the calling method

standardDialog

public static DialogBox standardDialog(java.lang.String tit,
                                       java.lang.String msg,
                                       java.lang.String but,
                                       java.awt.Image img)
Static utility method to create a standard Dialog with optional image

Parameters:
tit - title string
msg - message to show
but - comma separated list of dialog buttons
img - optional image to show on left hand side

errorDialog

public static DialogBox errorDialog(java.lang.String msg)
Static utility method to create a standard error dialog


warnDialog

public static DialogBox warnDialog(java.lang.String msg)
Static utility method to create a standard warning dialog.

Parameters:
msg - the warning message

infoDialog

public static DialogBox infoDialog(java.lang.String msg)
Static utility method to create a standard info dialog.

Parameters:
msg - the info message

busyDialog

public static DialogBox busyDialog(java.lang.String msg)
Static utility method to create a standard busy dialog.

Parameters:
msg - the info message

[.home.]
[.hacks.]
[.java.]