Class JXLoginPane
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jdesktop.swingx.JXPanel
-
- org.jdesktop.swingx.JXLoginPane
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.Scrollable,AlphaPaintable,BackgroundPaintable
@JavaBean public class JXLoginPane extends JXPanel
JXLoginPane is a specialized JPanel that implements a Login dialog with support for saving passwords supplied for future use in a secure manner. LoginService is invoked to perform authentication and optional PasswordStore can be provided to store the user login information.
In order to perform the authentication, JXLoginPane calls the
authenticatemethod of the LoginService . In order to perform the persistence of the password, JXLoginPane calls the put method of the PasswordStore object that is supplied. If the PasswordStore isnull, 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 thegetmethod. Example:final JXLoginPane panel = new JXLoginPane(new LoginService() { public boolean authenticate(String name, char[] password, String server) throws Exception { // perform authentication and return true on success. return false; }}); final JFrame frame = JXLoginPane.showLoginFrame(panel);- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJXLoginPane.CancelActionAction that cancels the login procedure.private classJXLoginPane.ComboNamePanelIf 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 nameprivate static classJXLoginPane.JXBtnPanelstatic classJXLoginPane.JXLoginDialogstatic classJXLoginPane.JXLoginFrameprivate static classJXLoginPane.LoginActionAction that initiates a login procedure.protected classJXLoginPane.LoginListenerImplListener class to track state in the LoginServiceprivate classJXLoginPane.LoginPaneLayoutprivate static interfaceJXLoginPane.NameComponentprivate static classJXLoginPane.NullLoginServiceSimple login service that allows everybody to login.private static classJXLoginPane.NullPasswordStoreSimple PasswordStore that does not remember passwordsstatic classJXLoginPane.SaveModeThe JXLoginPane can attempt to save certain user information such as the username, password, or both to their respective stores.private classJXLoginPane.SimpleNamePanelIf a UserNameStore is not used, then this text field is presented allowing the user to simply enter their user namestatic classJXLoginPane.StatusReturns the status of the login process-
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
-
-
Field Summary
Fields Modifier and Type Field Description private JXImagePanelbannerAn optional banner at the top of the panelprivate java.lang.StringbannerTextText that should appear on the bannerprivate JXLoginPane.JXBtnPanelbuttonPanelLogin/cancel control pane;static java.lang.StringCANCEL_LOGIN_ACTION_COMMANDAction key for an Action in the ActionMap that cancels the Login procedureprivate javax.swing.JLabelcapsOnLabel displayed whenever caps lock is on.private static java.lang.StringCLASS_NAMEUsed as a prefix when pulling data out of UIManager for i18nprivate javax.swing.JPanelcontentCardPaneCard pane holding user/pwd fields view and the progress view.private JXPanelcontentPanelThe panel on which the input fields, messageLabel, and errorMessageLabel are placed.private LoginListenerdefaultLoginListenerThe default login listener used by this panel.private JXLabelerrorMessageLabelShows an error message such as "user name or password incorrect" or "could not contact server" or something like that if something goes wrongprivate booleanisErrorMessageSetprivate static java.util.logging.LoggerLOGThe Loggerstatic java.lang.StringLOGIN_ACTION_COMMANDAction key for an Action in the ActionMap that initiates the Login procedureprivate JXPanelloginPanelA Panel containing all of the input fields, check boxes, etc necessary for the user to do their job.private LoginServiceloginServiceThe LoginService to use.private javax.swing.JLabelmessageLabelCustom label allowing the developer to display some message to the userprivate JXLoginPane.NameComponentnamePanelThis is the area in which the name field is placed.private booleannamePanelEnabledprivate java.awt.CursoroldCursorTracks the cursor at the time that authentication was started, and restores to that cursor after authentication ends, or is canceled;private javax.swing.JPasswordFieldpasswordFieldThe password field presented allowing the user to enter their passwordprivate PasswordStorepasswordStoreOptional: a PasswordStore to use for storing and retrieving passwords for a specific user.private javax.swing.JLabelprogressMessageLabelA JLabel on the progressPanel that is used for informing the user of the status of the login procedure (logging in..., canceling login...)private JXPanelprogressPanelA special panel that displays a progress bar and cancel button, and which notify the user of the login process, and allow them to cancel that process.private javax.swing.JCheckBoxsaveCBCheck box presented if a PasswordStore is used, allowing the user to decide whether to save their passwordprivate JXLoginPane.SaveModesaveModeWhether to save password or username or both.private static longserialVersionUIDComment forserialVersionUIDprivate javax.swing.JComboBoxserverComboA combo box presenting the user with a list of servers to which they may log in.private java.util.List<java.lang.String>serversA list of servers where each server is represented by a String.private JXLoginPane.StatusstatusThe current login status for this panelstatic java.lang.StringuiClassIDUI Class IDprivate UserNameStoreuserNameStoreOptional: a UserNameStore to use for storing user names and retrieving them-
Fields inherited from class org.jdesktop.swingx.JXPanel
fakeTransparent
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description JXLoginPane()Create aJXLoginPanethat always accepts the user, never stores passwords or user ids, and has no target servers.JXLoginPane(LoginService service)Create aJXLoginPanewith the specifiedLoginServicethat does not store user ids or passwords and has no target servers.JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore)Create aJXLoginPanewith the specifiedLoginService,PasswordStore, andUserNameStore, but without a server list.JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore, java.util.List<java.lang.String> servers)Create aJXLoginPanewith the specifiedLoginService,PasswordStore,UserNameStore, and server list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancelLogin()Cancels the login procedure.protected javax.swing.ActioncreateCancelAction()Create and return an Action for canceling loginprotected javax.swing.ActioncreateLoginAction()Create and return an Action for logging inprotected java.awt.ImagecreateLoginBanner()Create and return an image to use for the Banner.private JXPanelcreateLoginPanel()Creates and returns a new LoginPanel, based on the SaveMode state of the login panel.java.awt.ImagegetBanner()Return the image used as the bannerjava.lang.StringgetBannerText()Returns text used when creating the bannerprivate LoginListenergetDefaultLoginListener()java.lang.StringgetErrorMessage()Returns the error message for this login panelLoginServicegetLoginService()Gets the LoginService for this panel.java.lang.StringgetMessage()Returns the custom message for this login panelchar[]getPassword()Gets the Password for this panel.PasswordStoregetPasswordStore()Gets the PasswordStore for this panel.JXLoginPane.SaveModegetSaveMode()java.util.List<java.lang.String>getServers()JXLoginPane.StatusgetStatus()Returns the panel's statusLoginPaneUIgetUI()java.lang.StringgetUIClassID()Returns the name of the L&F class that renders this component.java.lang.StringgetUserName()Gets the User name for this panel.UserNameStoregetUserNameStore()Gets theUserNameStorefor this panel.private voidinitComponents()Create all of the UI components for the login panel(package private) static voidinitWindow(java.awt.Window w, JXLoginPane panel)Utility method for initializing a Window for displaying a LoginDialog.booleanisCapsLockOn()Gets current state of the caps lock as seen by the login panel.booleanisRememberPassword()booleanisUserNameEnabled()Gets current state of the user name field.protected voidrecreateLoginPanel()Recreates the login panel, and replaces the current one with the new oneprivate voidreinitLocales(java.util.Locale l)Populates UIDefaults with the localizable Strings we will use in the Login panel.protected voidsavePassword()Puts the password into the password store.voidsetBanner(java.awt.Image img)Set the image to use for the banner.voidsetBannerText(java.lang.String text)Set the text to use when creating the banner.private voidsetButtonPanel(JXLoginPane.JXBtnPanel buttonPanel)voidsetComponentOrientation(java.awt.ComponentOrientation orient)This method adds functionality to support bidi languages within this componentvoidsetErrorMessage(java.lang.String errorMessage)Sets the error message for this login panelvoidsetLocale(java.util.Locale l)voidsetLoginService(LoginService service)Sets theLoginServicefor this panel.voidsetMessage(java.lang.String message)Sets a custom message for this login panelvoidsetPassword(char[] password)Sets the Password for this panel.voidsetPasswordStore(PasswordStore store)Sets the PasswordStore for this panel.voidsetSaveMode(JXLoginPane.SaveMode saveMode)The save mode indicates whether the "save" password is checked by default.voidsetServers(java.util.List<java.lang.String> servers)Sets the list of servers.protected voidsetStatus(JXLoginPane.Status newStatus)Change the statusvoidsetUI(LoginPaneUI ui)Sets the look and feel (L&F) object that renders this component.voidsetUserName(java.lang.String username)Sets the User name for this panel.voidsetUserNameEnabled(boolean enabled)Enables or disables User name for this panel.voidsetUserNameStore(UserNameStore store)Sets the user name store for this panel.static JXLoginPane.StatusshowLoginDialog(java.awt.Component parent, LoginService svc)Shows a login dialog.static JXLoginPane.StatusshowLoginDialog(java.awt.Component parent, LoginService svc, PasswordStore ps, UserNameStore us)Shows a login dialog.static JXLoginPane.StatusshowLoginDialog(java.awt.Component parent, LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)Shows a login dialog.static JXLoginPane.StatusshowLoginDialog(java.awt.Component parent, JXLoginPane panel)Shows a login dialog.static JXLoginPane.JXLoginFrameshowLoginFrame(LoginService svc)Shows a login frame.static JXLoginPane.JXLoginFrameshowLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us)static JXLoginPane.JXLoginFrameshowLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)static JXLoginPane.JXLoginFrameshowLoginFrame(JXLoginPane panel)protected voidstartLogin()Initiates the login procedure.private voidupdatePassword(java.lang.String username)voidupdateUI()Notification from theUIManagerthat the L&F has changed.-
Methods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPainterChangeListener, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableHeightHint, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollableWidthHint, installRepaintManager, isAlpha, isInheritAlpha, isOpaque, isOpaquePatch, isPaintBorderInsets, isPaintingBackground, isPaintingOrigin, isPatch, isTransparentBackground, paint, paintComponent, paintComponentPatch, setAlpha, setBackgroundPainter, setInheritAlpha, setOpaque, setOpaquePatch, setPaintBorderInsets, setScrollableHeightHint, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth, setScrollableWidthHint, uninstallRepaintManager
-
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setPreferredSize, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
LOG
private static final java.util.logging.Logger LOG
The Logger
-
serialVersionUID
private static final long serialVersionUID
Comment forserialVersionUID- See Also:
- Constant Field Values
-
uiClassID
public static final java.lang.String uiClassID
UI Class ID- See Also:
- Constant Field Values
-
LOGIN_ACTION_COMMAND
public static final java.lang.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 java.lang.String CANCEL_LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that cancels the Login procedure- See Also:
- Constant Field Values
-
CLASS_NAME
private static java.lang.String CLASS_NAME
Used as a prefix when pulling data out of UIManager for i18n
-
status
private JXLoginPane.Status status
The current login status for this panel
-
banner
private JXImagePanel banner
An optional banner at the top of the panel
-
bannerText
private java.lang.String bannerText
Text that should appear on the banner
-
messageLabel
private javax.swing.JLabel messageLabel
Custom label allowing the developer to display some message to the user
-
errorMessageLabel
private JXLabel errorMessageLabel
Shows an error message such as "user name or password incorrect" or "could not contact server" or something like that if something goes wrong
-
loginPanel
private JXPanel loginPanel
A Panel containing all of the input fields, check boxes, etc necessary for the user to do their job. The items on this panel change whenever the SaveMode changes, so this panel must be recreated at runtime if the SaveMode changes. Thus, I must maintain this reference so I can remove this panel from the content panel at runtime.
-
contentPanel
private JXPanel contentPanel
The panel on which the input fields, messageLabel, and errorMessageLabel are placed. While the login thread is running, this panel is removed from the dialog and replaced by the progressPanel
-
namePanel
private JXLoginPane.NameComponent namePanel
This is the area in which the name field is placed. That way it can toggle on the fly between text field and a combo box depending on the situation, and have a simple way to get the user name
-
passwordField
private javax.swing.JPasswordField passwordField
The password field presented allowing the user to enter their password
-
serverCombo
private javax.swing.JComboBox serverCombo
A combo box presenting the user with a list of servers to which they may log in. This is an optional feature, which is only enabled if the List of servers supplied to the JXLoginPane has a length greater than 1.
-
saveCB
private javax.swing.JCheckBox saveCB
Check box presented if a PasswordStore is used, allowing the user to decide whether to save their password
-
capsOn
private javax.swing.JLabel capsOn
Label displayed whenever caps lock is on.
-
progressPanel
private JXPanel progressPanel
A special panel that displays a progress bar and cancel button, and which notify the user of the login process, and allow them to cancel that process.
-
progressMessageLabel
private javax.swing.JLabel progressMessageLabel
A JLabel on the progressPanel that is used for informing the user of the status of the login procedure (logging in..., canceling login...)
-
loginService
private LoginService loginService
The LoginService to use. This must be specified for the login dialog to operate. If no LoginService is defined, a default login service is used that simply allows all users access. This is useful for demos or prototypes where a proper login server is not available.
-
passwordStore
private PasswordStore passwordStore
Optional: a PasswordStore to use for storing and retrieving passwords for a specific user.
-
userNameStore
private UserNameStore userNameStore
Optional: a UserNameStore to use for storing user names and retrieving them
-
servers
private java.util.List<java.lang.String> servers
A list of servers where each server is represented by a String. If the list of Servers is greater than 1, then a combo box will be presented to the user to choose from. If any servers are specified, the selected one (or the only one if servers.size() == 1) will be passed to the LoginService
-
saveMode
private JXLoginPane.SaveMode saveMode
Whether to save password or username or both.
-
oldCursor
private java.awt.Cursor oldCursor
Tracks the cursor at the time that authentication was started, and restores to that cursor after authentication ends, or is canceled;
-
namePanelEnabled
private boolean namePanelEnabled
-
defaultLoginListener
private LoginListener defaultLoginListener
The default login listener used by this panel.
-
buttonPanel
private JXLoginPane.JXBtnPanel buttonPanel
Login/cancel control pane;
-
contentCardPane
private javax.swing.JPanel contentCardPane
Card pane holding user/pwd fields view and the progress view.
-
isErrorMessageSet
private boolean isErrorMessageSet
-
-
Constructor Detail
-
JXLoginPane
public JXLoginPane()
Create aJXLoginPanethat always accepts the user, never stores passwords or user ids, and has no target servers.This constructor should NOT be used in a real application. It is provided for compliance to the bean specification and for use with visual editors.
-
JXLoginPane
public JXLoginPane(LoginService service)
Create aJXLoginPanewith the specifiedLoginServicethat does not store user ids or passwords and has no target servers.- Parameters:
service- theLoginServiceto use for logging in
-
JXLoginPane
public JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore)
Create aJXLoginPanewith the specifiedLoginService,PasswordStore, andUserNameStore, but without a server list.If you do not want to store passwords or user ids, those parameters can be
null.SaveModeis autoconfigured from passed in store parameters.- Parameters:
service- theLoginServiceto use for logging inpasswordStore- thePasswordStoreto use for storing password informationuserStore- theUserNameStoreto use for storing user information
-
JXLoginPane
public JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore, java.util.List<java.lang.String> servers)
Create aJXLoginPanewith the specifiedLoginService,PasswordStore,UserNameStore, and server list.If you do not want to store passwords or user ids, those parameters can be
null.SaveModeis autoconfigured from passed in store parameters.Setting the server list to
nullwill unset all of the servers. The server list is guaranteed to be non-null.- Parameters:
service- theLoginServiceto use for logging inpasswordStore- thePasswordStoreto use for storing password informationuserStore- theUserNameStoreto use for storing user informationservers- a list of servers to authenticate against
-
-
Method Detail
-
reinitLocales
private void reinitLocales(java.util.Locale l)
Populates UIDefaults with the localizable Strings we will use in the Login panel.
-
isCapsLockOn
public boolean isCapsLockOn()
Gets current state of the caps lock as seen by the login panel. The state seen by the login panel and therefore returned by this method can be delayed in comparison to the real caps lock state and displayed by the keyboard light. This is usually the case when component or its text fields are not focused.- Returns:
- True when caps lock is on, false otherwise. Returns always false when
isCapsLockDetectionSupported()returns false.
-
getUI
public LoginPaneUI getUI()
- Overrides:
getUIin classjavax.swing.JPanel
-
setUI
public void setUI(LoginPaneUI ui)
Sets the look and feel (L&F) object that renders this component.- Parameters:
ui- the LoginPaneUI L&F object- See Also:
UIDefaults.getUI(javax.swing.JComponent)
-
updateUI
public void updateUI()
Notification from theUIManagerthat the L&F has changed. Replaces the current UI object with the latest version from theUIManager.- Overrides:
updateUIin classjavax.swing.JPanel- See Also:
JComponent.updateUI()
-
getUIClassID
public java.lang.String getUIClassID()
Returns the name of the L&F class that renders this component.- Overrides:
getUIClassIDin classjavax.swing.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
-
createLoginPanel
private JXPanel createLoginPanel()
Creates and returns a new LoginPanel, based on the SaveMode state of the login panel. Whenever the SaveMode changes, the panel is recreated. I do this rather than hiding/showing components, due to a cleaner implementation (no invisible components, components are not sharing locations in the LayoutManager, etc).
-
setComponentOrientation
public void setComponentOrientation(java.awt.ComponentOrientation orient)
This method adds functionality to support bidi languages within this component- Overrides:
setComponentOrientationin classjava.awt.Component
-
initComponents
private void initComponents()
Create all of the UI components for the login panel
-
createLoginBanner
protected java.awt.Image createLoginBanner()
Create and return an image to use for the Banner. This may be overridden to return any image you like
-
createLoginAction
protected javax.swing.Action createLoginAction()
Create and return an Action for logging in
-
createCancelAction
protected javax.swing.Action createCancelAction()
Create and return an Action for canceling login
-
getSaveMode
public JXLoginPane.SaveMode getSaveMode()
- Returns:
- Returns the saveMode.
-
setSaveMode
public void setSaveMode(JXLoginPane.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
-
isRememberPassword
public boolean isRememberPassword()
-
getServers
public java.util.List<java.lang.String> getServers()
- Returns:
- the List of servers
-
setServers
public void setServers(java.util.List<java.lang.String> servers)
Sets the list of servers. See the servers field javadoc for more info.
-
getDefaultLoginListener
private LoginListener getDefaultLoginListener()
-
setLoginService
public void setLoginService(LoginService service)
Sets theLoginServicefor this panel. Setting the login service tonullwill actually set the service to useNullLoginService.- Parameters:
service- the service to set. Ifservice == null, then aNullLoginServiceis used.
-
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
-
getUserNameStore
public UserNameStore getUserNameStore()
Gets theUserNameStorefor this panel.- Returns:
- the
UserNameStore
-
setUserNameStore
public void setUserNameStore(UserNameStore store)
Sets the user name store for this panel.- Parameters:
store-
-
getPasswordStore
public PasswordStore getPasswordStore()
Gets the PasswordStore for this panel.- Returns:
- store PasswordStore
-
setUserName
public void setUserName(java.lang.String username)
Sets the User name for this panel.- Parameters:
username- User name
-
setUserNameEnabled
public void setUserNameEnabled(boolean enabled)
Enables or disables User name for this panel.- Parameters:
enabled-
-
isUserNameEnabled
public boolean isUserNameEnabled()
Gets current state of the user name field. Field can be either disabled (false) for editing or enabled (true).- Returns:
- True when user name field is enabled and editable, false otherwise.
-
getUserName
public java.lang.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 java.awt.Image getBanner()
Return the image used as the banner
-
setBanner
public void setBanner(java.awt.Image img)
Set the image to use for the banner. If theimgisnull, then no image will be displayed.- Parameters:
img- the image to display
-
setBannerText
public void setBannerText(java.lang.String text)
Set the text to use when creating the banner. If a custom banner image is specified, then this is ignored. Iftextisnull, then no text is displayed.- Parameters:
text- the text to display
-
getBannerText
public java.lang.String getBannerText()
Returns text used when creating the banner
-
getMessage
public java.lang.String getMessage()
Returns the custom message for this login panel
-
setMessage
public void setMessage(java.lang.String message)
Sets a custom message for this login panel
-
getErrorMessage
public java.lang.String getErrorMessage()
Returns the error message for this login panel
-
setErrorMessage
public void setErrorMessage(java.lang.String errorMessage)
Sets the error message for this login panel
-
getStatus
public JXLoginPane.Status getStatus()
Returns the panel's status
-
setStatus
protected void setStatus(JXLoginPane.Status newStatus)
Change the status
-
setLocale
public void setLocale(java.util.Locale l)
- Overrides:
setLocalein classjava.awt.Component
-
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. Method will return immediately if asynchronous login is enabled or will block until authentication finishes ifgetSynchronous()returns true.
-
cancelLogin
protected void cancelLogin()
Cancels the login procedure. Handles cursor management and interfacing with the LoginService's cancelAuthentication method. Calling this method has an effect only when authentication is still in progress (i.e. after previous call tostartAuthentications()and only when authentication is performed asynchronously (getSynchronous()returns false).
-
savePassword
protected void savePassword()
Puts the password into the password store. If password store is not set, method will do nothing.
-
updatePassword
private void updatePassword(java.lang.String username)
-
showLoginDialog
public static JXLoginPane.Status showLoginDialog(java.awt.Component parent, LoginService svc)
Shows a login dialog. This method blocks.- Returns:
- The status of the login operation
-
showLoginDialog
public static JXLoginPane.Status showLoginDialog(java.awt.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 JXLoginPane.Status showLoginDialog(java.awt.Component parent, LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)
Shows a login dialog. This method blocks.- Returns:
- The status of the login operation
-
showLoginDialog
public static JXLoginPane.Status showLoginDialog(java.awt.Component parent, JXLoginPane panel)
Shows a login dialog. This method blocks.- Returns:
- The status of the login operation
-
showLoginFrame
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc)
Shows a login frame. A JFrame is not modal, and thus does not block
-
showLoginFrame
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us)
-
showLoginFrame
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us, java.util.List<java.lang.String> servers)
-
showLoginFrame
public static JXLoginPane.JXLoginFrame showLoginFrame(JXLoginPane panel)
-
initWindow
static void initWindow(java.awt.Window w, JXLoginPane panel)Utility method for initializing a Window for displaying a LoginDialog. This is particularly useful because the differences between JFrame and JDialog are so minor. Note: This method is package private for use by JXLoginDialog (proper, not JXLoginPane.JXLoginDialog). Change to private if JXLoginDialog is removed.
-
setButtonPanel
private void setButtonPanel(JXLoginPane.JXBtnPanel buttonPanel)
-
-