|
|||||||||||
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.ptc.wgmecad.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()){
logger.debug("Name: " + p.getAssemblyName());
logger.debug("Pass: " + p.getPass());
} else {
logger.debug("User selected cancel");
}
Nested Class Summary |
Nested classes inherited from class javax.swing.JDialog |
JDialog.AccessibleJDialog |
Nested classes inherited from class java.awt.Dialog |
Dialog.AccessibleAWTDialog |
Nested classes inherited from class java.awt.Window |
Window.AccessibleAWTWindow |
Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
protected JButton |
cancelButton
The cancel button. |
(package private) static org.apache.log4j.Logger |
logger
|
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. |
private boolean |
pressed_OK
update this variable when the user makes an action |
Fields inherited from class javax.swing.JDialog |
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Dialog |
|
Fields inherited from class java.awt.Window |
|
Fields inherited from class java.awt.Container |
|
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(Frame owner)
|
|
PasswordDialog(JFrame 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. |
static void |
main(String[] args)
A simple example to show how this might be used. |
boolean |
okPressed()
Finds out if user used the OK button or an equivalent action to close the dialog. |
private static void |
resetContstraints(GridBagConstraints con,
int gridx,
int gridy,
int anchor)
|
void |
setCancelText(String cancel)
Set the label on the cancel button. |
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, dispose, 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 |
static org.apache.log4j.Logger logger
protected JTextField name
protected JPasswordField pass
protected JButton okButton
protected JButton cancelButton
protected JLabel nameLabel
protected JLabel passLabel
private boolean pressed_OK
Constructor Detail |
public PasswordDialog(Frame owner)
public PasswordDialog(JFrame parent, String title)
parent
- window from which this dialog is launchedtitle
- the title for the dialog box windowMethod Detail |
public void setName(String name)
name
- 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()
public String getPass()
public boolean okPressed()
protected void dialogInit()
private static void resetContstraints(GridBagConstraints con, int gridx, int gridy, int anchor)
public boolean showDialog()
public static void main(String[] args)
args
- command line arguments: name and password (optional)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |