ccs.utils
Class PasswordDialog

java.lang.Object
  extended by ccs.utils.PasswordDialog

public class PasswordDialog
extends java.lang.Object

Displays a dialog to let the user type in a password, with it not being echoed to the screen. This is a utility wrapper around Swing's JOPtionPane. As such, it shares the window-title bug described in MsgBox.

See Also:
MsgBox

Constructor Summary
PasswordDialog(java.awt.Frame frame, java.lang.String title, boolean isConfirm)
          Creates a new password dialog, initially invisible.
PasswordDialog(java.awt.Frame frame, java.lang.String title, boolean isConfirm, boolean isThrow)
          Creates a new password dialog, initially invisible.
 
Method Summary
 java.lang.String getResult()
          Returns the result: the password if the user selected OK (and both entries matched where confirmation was specified in the constructor), otherwise null.
 void show()
          Shows the dialog, modally.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordDialog

public PasswordDialog(java.awt.Frame frame,
                      java.lang.String title,
                      boolean isConfirm,
                      boolean isThrow)
Creates a new password dialog, initially invisible.

Parameters:
frame - The parent frame of the dialog. May be null.
title - The title of the dialog.
isConfirm - True to make the user enter the same password twice (e.g. when defining a new password).
isThrow - Throw IllegalArgumentException for non-matching passwords. Ignored unless isConfirm true. If false, a mismatch generates a message from the dialog, and a null result, as though cancelled.

PasswordDialog

public PasswordDialog(java.awt.Frame frame,
                      java.lang.String title,
                      boolean isConfirm)
Creates a new password dialog, initially invisible. Equivalent to the constructor of four arguments, with isThrow false.

Parameters:
frame - The parent frame of the dialog. May be null.
title - The title of the dialog.
isConfirm - True to make the user enter the same password twice (e.g. when defining a new password).
Method Detail

show

public void show()
Shows the dialog, modally. The app will block until the user closes the dialog.


getResult

public java.lang.String getResult()
Returns the result: the password if the user selected OK (and both entries matched where confirmation was specified in the constructor), otherwise null. A zero-length password will return a zero-length string, not null.

Returns:
The password, or null.