swingx
Version 2005-08-19

org.jdesktop.swingx
Class JXLoginPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.jdesktop.swingx.JXPanel
                      extended by org.jdesktop.swingx.JXImagePanel
                          extended by org.jdesktop.swingx.JXLoginPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class JXLoginPanel
extends JXImagePanel

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.

See Also:
Serialized Form

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
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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
static String CANCEL_LOGIN_ACTION_COMMAND
          Action key for an Action in the ActionMap that cancels the Login procedure
static String LOGIN_ACTION_COMMAND
          Action key for an Action in the ActionMap that initiates the Login procedure
static 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, List<String> servers)
          Create a new JXLoginPanel
 
Method Summary
protected  void cancelLogin()
          Cancels the login procedure.
protected  Action createCancelAction()
          Create and return an Action for canceling login
protected  Action createLoginAction()
          Create and return an Action for logging in
protected  Image createLoginBanner()
          Create and return an image to use for the Banner.
 Image getBanner()
          Return the image used as the banner
 String getBannerText()
          Returns text used when creating the banner
 String getErrorMessage()
          Returns the error message for this login panel
 LoginService getLoginService()
          Gets the LoginService for this panel.
 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()
           
 List<String> getServers()
           
 JXLoginPanel.Status getStatus()
          Returns the panel's status
 LoginPanelUI getUI()
           
 String getUIClassID()
          Returns the name of the L&F class that renders this component.
 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(Image img)
          Set the image to use for the banner
 void setBannerText(String text)
          Set the text to use when creating the banner.
 void setComponentOrientation(ComponentOrientation orient)
          This method adds functionality to support bidi languages within this component
 void setErrorMessage(String errorMessage)
          Sets the error message for this login panel
 void setLoginService(LoginService service)
          Sets the LoginService for this panel.
 void setMessage(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(List<String> servers)
          Sets the list of servers.
protected  void setStatus(JXLoginPanel.Status newStatus)
          Change the status
 void setUserName(String username)
          Sets the User name for this panel.
static JXLoginPanel.Status showLoginDialog(Component parent, JXLoginPanel panel)
          Shows a login dialog.
static JXLoginPanel.Status showLoginDialog(Component parent, LoginService svc)
          Shows a login dialog.
static JXLoginPanel.Status showLoginDialog(Component parent, LoginService svc, PasswordStore ps, UserNameStore us)
          Shows a login dialog.
static JXLoginPanel.Status showLoginDialog(Component parent, LoginService svc, PasswordStore ps, UserNameStore us, List<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, List<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 org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getGradientPaint, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isDrawGradient, isGradientTrackHeight, isGradientTrackWidth, isInheritAlpha, paint, setAlpha, setBackgroundPainter, setDrawGradient, setGradientPaint, setGradientTrackHeight, setGradientTrackWidth, setInheritAlpha, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth
 
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, 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

uiClassID

public static final String uiClassID
UI Class ID

See Also:
Constant Field Values

LOGIN_ACTION_COMMAND

public static final String LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that initiates the Login procedure

See Also:
Constant Field Values

CANCEL_LOGIN_ACTION_COMMAND

public static final String CANCEL_LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that cancels the Login procedure

See Also:
Constant Field Values
Constructor Detail

JXLoginPanel

public JXLoginPanel()
Create a new JXLoginPanel


JXLoginPanel

public JXLoginPanel(LoginService service)
Create a new JXLoginPanel

Parameters:
service - The LoginService to use for logging in

JXLoginPanel

public JXLoginPanel(LoginService service,
                    PasswordStore passwordStore,
                    UserNameStore userStore)
Create a new JXLoginPanel

Parameters:
service -
passwordStore -
userStore -

JXLoginPanel

public JXLoginPanel(LoginService service,
                    PasswordStore passwordStore,
                    UserNameStore userStore,
                    List<String> servers)
Create a new JXLoginPanel

Parameters:
service -
passwordStore -
userStore -
servers -
Method Detail

getUI

public LoginPanelUI getUI()
Overrides:
getUI in class JPanel

getUIClassID

public String getUIClassID()
Returns the name of the L&F class that renders this component.

Overrides:
getUIClassID in class JPanel
Returns:
the string uiClassID
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

recreateLoginPanel

protected void recreateLoginPanel()
Recreates the login panel, and replaces the current one with the new one


setComponentOrientation

public void setComponentOrientation(ComponentOrientation orient)
This method adds functionality to support bidi languages within this component

Overrides:
setComponentOrientation in class Component

createLoginBanner

protected Image createLoginBanner()
Create and return an image to use for the Banner. This may be overridden to return any image you like


createLoginAction

protected Action createLoginAction()
Create and return an Action for logging in


createCancelAction

protected Action createCancelAction()
Create and return an Action for canceling login


getSaveMode

public JXLoginPanel.SaveMode getSaveMode()
Returns:
Returns the saveMode.

setSaveMode

public void setSaveMode(JXLoginPanel.SaveMode saveMode)
The save mode indicates whether the "save" password is checked by default. This method makes no difference if the passwordStore is null.

Parameters:
saveMode - The saveMode to set either SAVE_NONE, SAVE_PASSWORD or SAVE_USERNAME

getServers

public List<String> getServers()
Returns:
the List of servers

setServers

public void setServers(List<String> servers)
Sets the list of servers. See the servers field javadoc for more info


setLoginService

public void setLoginService(LoginService service)
Sets the LoginService for this panel.

Parameters:
service - service

getLoginService

public LoginService getLoginService()
Gets the LoginService for this panel.

Returns:
service service

setPasswordStore

public void setPasswordStore(PasswordStore store)
Sets the PasswordStore for this panel.

Parameters:
store - PasswordStore

getPasswordStore

public PasswordStore getPasswordStore()
Gets the PasswordStore for this panel.

Returns:
store PasswordStore

setUserName

public void setUserName(String username)
Sets the User name for this panel.

Parameters:
username - User name

getUserName

public String getUserName()
Gets the User name for this panel.

Returns:
the user name

setPassword

public void setPassword(char[] password)
Sets the Password for this panel.

Parameters:
password - Password

getPassword

public char[] getPassword()
Gets the Password for this panel.

Returns:
password Password

getBanner

public Image getBanner()
Return the image used as the banner


setBanner

public void setBanner(Image img)
Set the image to use for the banner


setBannerText

public void setBannerText(String text)
Set the text to use when creating the banner. If a custom banner image is specified, then this is ignored


getBannerText

public String getBannerText()
Returns text used when creating the banner


getMessage

public String getMessage()
Returns the custom message for this login panel


setMessage

public void setMessage(String message)
Sets a custom message for this login panel


getErrorMessage

public String getErrorMessage()
Returns the error message for this login panel


setErrorMessage

public void setErrorMessage(String errorMessage)
Sets the error message for this login panel


getStatus

public JXLoginPanel.Status getStatus()
Returns the panel's status


setStatus

protected void setStatus(JXLoginPanel.Status newStatus)
Change the status


startLogin

protected void startLogin()
Initiates the login procedure. This method is called internally by the LoginAction. This method handles cursor management, and actually calling the LoginService's startAuthentication method.


cancelLogin

protected void cancelLogin()
Cancels the login procedure. Handles cursor management and interfacing with the LoginService's cancelAuthentication method


savePassword

protected void savePassword()
TODO


showLoginDialog

public static JXLoginPanel.Status showLoginDialog(Component parent,
                                                  LoginService svc)
Shows a login dialog. This method blocks.

Returns:
The status of the login operation

showLoginDialog

public static JXLoginPanel.Status showLoginDialog(Component parent,
                                                  LoginService svc,
                                                  PasswordStore ps,
                                                  UserNameStore us)
Shows a login dialog. This method blocks.

Returns:
The status of the login operation

showLoginDialog

public static JXLoginPanel.Status showLoginDialog(Component parent,
                                                  LoginService svc,
                                                  PasswordStore ps,
                                                  UserNameStore us,
                                                  List<String> servers)
Shows a login dialog. This method blocks.

Returns:
The status of the login operation

showLoginDialog

public static JXLoginPanel.Status showLoginDialog(Component parent,
                                                  JXLoginPanel panel)
Shows a login dialog. This method blocks.

Returns:
The status of the login operation

showLoginFrame

public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc)
Shows a login frame. A JFrame is not modal, and thus does not block


showLoginFrame

public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc,
                                                       PasswordStore ps,
                                                       UserNameStore us)

showLoginFrame

public static JXLoginPanel.JXLoginFrame showLoginFrame(LoginService svc,
                                                       PasswordStore ps,
                                                       UserNameStore us,
                                                       List<String> servers)

showLoginFrame

public static JXLoginPanel.JXLoginFrame showLoginFrame(JXLoginPanel panel)

swingx
Version 2005-08-19