|
com.Ostermiller.util Java Utilities |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.Ostermiller.util.PasswordDialog
public class PasswordDialog
A modal dialog that asks the user for a user name and password.
More information about this class is available from ostermiller.org.
PasswordDialog p = new PasswordDialog(null, "Test");
if(p.showDialog()){
System.out.println("Name: " + p.getName());
System.out.println("Pass: " + p.getPass());
} else {
System.out.println("User selected cancel");
}
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
Dialog.AccessibleAWTDialog |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
Window.AccessibleAWTWindow |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected JButton |
cancelButton
The cancel button. |
protected ResourceBundle |
labels
Locale specific strings displayed to the user. |
protected JTextField |
name
Where the name is typed. |
protected JLabel |
nameLabel
The label for the field in which the name is typed. |
protected JButton |
okButton
The OK button. |
protected JPasswordField |
pass
Where the password is typed. |
protected JLabel |
passLabel
The label for the field in which the password is typed. |
| 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, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
PasswordDialog()
Create this dialog with the default title. |
|
PasswordDialog(Frame parent)
Create this dialog with the given parent and the default title. |
|
PasswordDialog(Frame parent,
String title)
Create this dialog with the given parent and title. |
|
| Method Summary | |
|---|---|
protected void |
dialogInit()
Called by constructors to initialize the dialog. |
String |
getName()
Get the name that was entered into the dialog before the dialog was closed. |
String |
getPass()
Get the password that was entered into the dialog before the dialog was closed. |
boolean |
okPressed()
Finds out if user used the OK button or an equivalent action to close the dialog. |
void |
setCancelText(String cancel)
Set the label on the cancel button. |
void |
setLocale(Locale locale)
Set the locale used for getting localized strings. |
void |
setName(String name)
Set the name that appears as the default An empty string will be used if this in not specified before the dialog is displayed. |
void |
setNameLabel(String name)
Set the label for the field in which the name is entered. |
void |
setOKText(String ok)
Set the label on the OK button. |
void |
setPass(String pass)
Set the password that appears as the default An empty string will be used if this in not specified before the dialog is displayed. |
void |
setPassLabel(String pass)
Set the label for the field in which the password is entered. |
boolean |
showDialog()
Shows the dialog and returns true if the user pressed ok. |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ResourceBundle labels
protected JTextField name
protected JPasswordField pass
protected JButton okButton
protected JButton cancelButton
protected JLabel nameLabel
protected JLabel passLabel
| Constructor Detail |
|---|
public PasswordDialog(Frame parent,
String title)
parent - window from which this dialog is launchedtitle - the title for the dialog box windowpublic PasswordDialog(Frame parent)
parent - window from which this dialog is launchedpublic PasswordDialog()
| Method Detail |
|---|
public void setLocale(Locale locale)
setLocale in class Componentlocale - Locale used to for i18n.public void setName(String name)
setName in class Componentname - default name to be displayed.public void setPass(String pass)
pass - default password to be displayed.public void setOKText(String ok)
ok - label for the ok button.public void setCancelText(String cancel)
cancel - label for the cancel button.public void setNameLabel(String name)
name - label for the name field.public void setPassLabel(String pass)
pass - label for the password field.public String getName()
getName in class Componentpublic String getPass()
public boolean okPressed()
protected void dialogInit()
dialogInit in class JDialogpublic boolean showDialog()
|
com.Ostermiller.util Java Utilities |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Copyright (c) 2001-2007 by Stephen Ostermiller