|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXPanel
org.jdesktop.swingx.JXImagePanel
org.jdesktop.swingx.JXLoginPanel
public class JXLoginPanel
JXLoginPanel is a JPanel that implements a Login dialog with support for saving passwords supplied for future use in a secure manner. It is intended to work with LoginService and PasswordStore to implement the authentication.
In order to perform the authentication, JXLoginPanel
calls the authenticate
method of the LoginService
. In order to perform the persistence of the password,
JXLoginPanel calls the put method of the
PasswordStore object that is supplied. If
the PasswordStore is null
, then the password
is not saved. Similarly, if a PasswordStore is
supplied and the password is null, then the PasswordStore
will be queried for the password using the get
method.
Changes by Shai:
Clarified the save mode a little bit including hiding the save checkbox when there
is no password store.
Changed the class to derive from JXImagePanel to make customization easier (need to
check my ImagePanel which has some technical advantages).
Removed the static keyword from the ok/cancel buttons since this can cause an issue
with more than one login dialogs (yes its an unlikely situation but documenting this
sort of behavior or dealing with one bug resulting from this can be a real pain!).
Allowed the name field to be represented as a text field when there is no password store.
Rewrote the layout code to mostly work with a single container.
Removed additional dialogs for progress and error messages and incorporated their
functionality into the main dialog.
Allowed for an IOException with a message to be thrown by the login code. This message
is displayed to the user when the login is stopped.
Removed repetetive code and moved it to a static block.
i18n converted some of the strings that were not localized.
Nested Class Summary | |
---|---|
static class |
JXLoginPanel.ComboNamePanel
If a UserNameStore is used, then this combo box is presented allowing the user to select a previous login name, or type in a new login name |
static class |
JXLoginPanel.JXLoginDialog
|
static class |
JXLoginPanel.JXLoginFrame
|
protected class |
JXLoginPanel.LoginListenerImpl
Listener class to track state in the LoginService |
static interface |
JXLoginPanel.NameComponent
|
static class |
JXLoginPanel.SaveMode
The JXLoginPanel can attempt to save certain user information such as the username, password, or both to their respective stores. |
static class |
JXLoginPanel.SimpleNamePanel
If a UserNameStore is not used, then this text field is presented allowing the user to simply enter their user name |
static class |
JXLoginPanel.Status
Returns the status of the login process |
Nested classes/interfaces inherited from class org.jdesktop.swingx.JXImagePanel |
---|
JXImagePanel.Style |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.lang.String |
CANCEL_LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that cancels the Login procedure |
static java.lang.String |
LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that initiates the Login procedure |
static java.lang.String |
uiClassID
UI Class ID |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JXLoginPanel()
Create a new JXLoginPanel |
|
JXLoginPanel(LoginService service)
Create a new JXLoginPanel |
|
JXLoginPanel(LoginService service,
PasswordStore passwordStore,
UserNameStore userStore)
Create a new JXLoginPanel |
|
JXLoginPanel(LoginService service,
PasswordStore passwordStore,
UserNameStore userStore,
java.util.List<java.lang.String> servers)
Create a new JXLoginPanel |
Method Summary | |
---|---|
protected void |
cancelLogin()
Cancels the login procedure. |
protected javax.swing.Action |
createCancelAction()
Create and return an Action for canceling login |
protected javax.swing.Action |
createLoginAction()
Create and return an Action for logging in |
protected java.awt.Image |
createLoginBanner()
Create and return an image to use for the Banner. |
java.awt.Image |
getBanner()
Return the image used as the banner |
java.lang.String |
getBannerText()
Returns text used when creating the banner |
java.lang.String |
getErrorMessage()
Returns the error message for this login panel |
LoginService |
getLoginService()
Gets the LoginService for this panel. |
java.lang.String |
getMessage()
Returns the custom message for this login panel |
char[] |
getPassword()
Gets the Password for this panel. |
PasswordStore |
getPasswordStore()
Gets the PasswordStore for this panel. |
JXLoginPanel.SaveMode |
getSaveMode()
|
java.util.List<java.lang.String> |
getServers()
|
JXLoginPanel.Status |
getStatus()
Returns the panel's status |
LoginPanelUI |
getUI()
|
java.lang.String |
getUIClassID()
Returns the name of the L&F class that renders this component. |
java.lang.String |
getUserName()
Gets the User name for this panel. |
protected void |
recreateLoginPanel()
Recreates the login panel, and replaces the current one with the new one |
protected void |
savePassword()
TODO |
void |
setBanner(java.awt.Image img)
Set the image to use for the banner |
void |
setBannerText(java.lang.String text)
Set the text to use when creating the banner. |
void |
setErrorMessage(java.lang.String errorMessage)
Sets the error message for this login panel |
void |
setLoginService(LoginService service)
Sets the LoginService for this panel. |
void |
setMessage(java.lang.String message)
Sets a custom message for this login panel |
void |
setPassword(char[] password)
Sets the Password for this panel. |
void |
setPasswordStore(PasswordStore store)
Sets the PasswordStore for this panel. |
void |
setSaveMode(JXLoginPanel.SaveMode saveMode)
The save mode indicates whether the "save" password is checked by default. |
void |
setServers(java.util.List<java.lang.String> servers)
Sets the list of servers. |
protected void |
setStatus(JXLoginPanel.Status newStatus)
Change the status |
void |
setUserName(java.lang.String username)
Sets the User name for this panel. |
static JXLoginPanel.Status |
showLoginDialog(javax.swing.JComponent parent,
JXLoginPanel panel)
Shows a login dialog. |
static JXLoginPanel.Status |
showLoginDialog(javax.swing.JComponent parent,
LoginService svc)
Shows a login dialog. |
static JXLoginPanel.Status |
showLoginDialog(javax.swing.JComponent parent,
LoginService svc,
PasswordStore ps,
UserNameStore us)
Shows a login dialog. |
static JXLoginPanel.Status |
showLoginDialog(javax.swing.JComponent parent,
LoginService svc,
PasswordStore ps,
UserNameStore us,
java.util.List<java.lang.String> servers)
Shows a login dialog. |
static JXLoginPanel.JXLoginFrame |
showLoginFrame(JXLoginPanel panel)
|
static JXLoginPanel.JXLoginFrame |
showLoginFrame(LoginService svc)
Shows a login frame. |
static JXLoginPanel.JXLoginFrame |
showLoginFrame(LoginService svc,
PasswordStore ps,
UserNameStore us)
|
static JXLoginPanel.JXLoginFrame |
showLoginFrame(LoginService svc,
PasswordStore ps,
UserNameStore us,
java.util.List<java.lang.String> servers)
|
protected void |
startLogin()
Initiates the login procedure. |
Methods inherited from class org.jdesktop.swingx.JXImagePanel |
---|
getImage, getPreferredSize, getStyle, isEditable, paintComponent, setEditable, setImage, setPreferredSize, setStyle |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String uiClassID
public static final java.lang.String LOGIN_ACTION_COMMAND
public static final java.lang.String CANCEL_LOGIN_ACTION_COMMAND
Constructor Detail |
---|
public JXLoginPanel()
public JXLoginPanel(LoginService service)
service
- The LoginService to use for logging inpublic JXLoginPanel(LoginService service, PasswordStore passwordStore, UserNameStore userStore)
service
- passwordStore
- userStore
- public JXLoginPanel(LoginService service, PasswordStore passwordStore, UserNameStore userStore, java.util.List<java.lang.String> servers)
service
- passwordStore
- userStore
- servers
- Method Detail |
---|
public LoginPanelUI getUI()
getUI
in class javax.swing.JPanel
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JPanel
uiClassID
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected void recreateLoginPanel()
protected java.awt.Image createLoginBanner()
protected javax.swing.Action createLoginAction()
protected javax.swing.Action createCancelAction()
public JXLoginPanel.SaveMode getSaveMode()
public void setSaveMode(JXLoginPanel.SaveMode saveMode)
saveMode
- The saveMode to set either SAVE_NONE, SAVE_PASSWORD or SAVE_USERNAMEpublic java.util.List<java.lang.String> getServers()
public void setServers(java.util.List<java.lang.String> servers)
public void setLoginService(LoginService service)
service
- servicepublic LoginService getLoginService()
public void setPasswordStore(PasswordStore store)
store
- PasswordStorepublic PasswordStore getPasswordStore()
public void setUserName(java.lang.String username)
username
- User namepublic java.lang.String getUserName()
public void setPassword(char[] password)
password
- Passwordpublic char[] getPassword()
public java.awt.Image getBanner()
public void setBanner(java.awt.Image img)
public void setBannerText(java.lang.String text)
public java.lang.String getBannerText()
public java.lang.String getMessage()
public void setMessage(java.lang.String message)
public java.lang.String getErrorMessage()
public void setErrorMessage(java.lang.String errorMessage)
public JXLoginPanel.Status getStatus()
protected void setStatus(JXLoginPanel.Status newStatus)
protected void startLogin()
protected void cancelLogin()
protected void savePassword()
public static JXLoginPanel.Status showLoginDialog(javax.swing.JComponent parent, LoginService svc)
public static JXLoginPanel.Status showLoginDialog(javax.swing.JComponent parent, LoginService svc, PasswordStore ps, UserNameStore us)
public static JXLoginPanel.Status showLoginDialog(javax.swing.JComponent parent, LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)
public static JXLoginPanel.Status showLoginDialog(javax.swing.JComponent parent, JXLoginPanel panel)
public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc)
public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us)
public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)
public static JXLoginPanel.JXLoginFrame showLoginFrame(JXLoginPanel panel)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |