com.Ostermiller.util
Class PasswordDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.Ostermiller.util.PasswordDialog
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
public class PasswordDialog
- extends JDialog
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");
}
- Since:
- ostermillerutils 1.00.00
- Author:
- Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
- See Also:
- Serialized Form
Method Summary |
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 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, paint, 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, 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, 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, setLocation, setLocation, setMaximumSize, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
PasswordDialog
public PasswordDialog(Frame parent,
String title)
- Create this dialog with the given parent and title.
- Parameters:
parent
- window from which this dialog is launchedtitle
- the title for the dialog box window- Since:
- ostermillerutils 1.00.00
PasswordDialog
public PasswordDialog(Frame parent)
- Create this dialog with the given parent and the default title.
- Parameters:
parent
- window from which this dialog is launched- Since:
- ostermillerutils 1.00.00
PasswordDialog
public PasswordDialog()
- Create this dialog with the default title.
- Since:
- ostermillerutils 1.00.00
setLocale
public void setLocale(Locale locale)
- Set the locale used for getting localized
strings.
- Overrides:
setLocale
in class Component
- Parameters:
locale
- Locale used to for i18n.- Since:
- ostermillerutils 1.00.00
setName
public 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.
- Overrides:
setName
in class Component
- Parameters:
name
- default name to be displayed.- Since:
- ostermillerutils 1.00.00
setPass
public 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.
- Parameters:
pass
- default password to be displayed.- Since:
- ostermillerutils 1.00.00
setOKText
public void setOKText(String ok)
- Set the label on the OK button.
The default is a localized string.
- Parameters:
ok
- label for the ok button.- Since:
- ostermillerutils 1.00.00
setCancelText
public void setCancelText(String cancel)
- Set the label on the cancel button.
The default is a localized string.
- Parameters:
cancel
- label for the cancel button.- Since:
- ostermillerutils 1.00.00
setNameLabel
public void setNameLabel(String name)
- Set the label for the field in which the name is entered.
The default is a localized string.
- Parameters:
name
- label for the name field.- Since:
- ostermillerutils 1.00.00
setPassLabel
public void setPassLabel(String pass)
- Set the label for the field in which the password is entered.
The default is a localized string.
- Parameters:
pass
- label for the password field.- Since:
- ostermillerutils 1.00.00
getName
public String getName()
- Get the name that was entered into the dialog before
the dialog was closed.
- Overrides:
getName
in class Component
- Returns:
- the name from the name field.
- Since:
- ostermillerutils 1.00.00
getPass
public String getPass()
- Get the password that was entered into the dialog before
the dialog was closed.
- Returns:
- the password from the password field.
- Since:
- ostermillerutils 1.00.00
okPressed
public boolean okPressed()
- Finds out if user used the OK button or an equivalent action
to close the dialog.
Pressing enter in the password field may be the same as
'OK' but closing the dialog and pressing the cancel button
are not.
- Returns:
- true if the the user hit OK, false if the user canceled.
- Since:
- ostermillerutils 1.00.00
showDialog
public boolean showDialog()
- Shows the dialog and returns true if the user pressed ok.
- Returns:
- true if the the user hit OK, false if the user canceled.
- Since:
- ostermillerutils 1.00.00
Copyright © 2001-2012 by Stephen Ostermiller