|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.util.login.LoginBeanSwingUtil
public class LoginBeanSwingUtil
The LoginBeanSwingUtil class is a Swing utility class for the LoginBean. It's primary purpose is to create a Swing panel using the properties set on a LoginBean.
It also has a static showDialog convenience method which will create and display a Swing dialog with the Swing panel mentioned above.
The following example illustrates a typical use of the LoginBean in conjunction with this class.
LoginBean bean = new LoginBean(); bean.setTitle("Enter your username and password:"); // Provide a default value for the username. bean.setUsername("James"); // Allow 2 retry attempts before failing (default is 3). bean.setAttempts(2); // Instantiate the LoginBeanSwingUtil class using the constructor which sets the // login bean as the model. LoginBeanSwingUtil beanUtil = new LoginBeanSwingUtil(bean); // Set our LoginBeanSwingUtil instance as the action handler for the login bean. // Note that this class implements LoginBeanActionInterface as a convenience for // typical usage scenarios. bean.setActionHandler(beanUtil); // Call the showDialog method to display a model Swing dialog with a visual representation // of the login bean. beanUtil.showDialog("LoginBean", null);
Note that in this example, no validation is handled on the information entered by the user. To do so, you can create a class that implements LoginBeanValidateInterface and implement the validate method such that it validates the specified credentials against whatever authentication system you have in place. Then set an instance of this class as the validation handler as follows:
bean.setValidateHandler(yourInstance);
See the LoginBeanBIPValidate class in this same package for an example that performs validation.
Field Summary | |
---|---|
protected int |
buttonSelected
An index representing the selected button. |
protected javax.swing.JButton |
cancelButton
The Cancel button. |
protected javax.swing.JButton |
closeButton
The Close button. |
protected javax.swing.JDialog |
dialog
The dialog used by the showDialog method. |
protected com.sas.util.login.LoginBean |
loginBean
The associated LoginBean. |
protected javax.swing.JButton |
okButton
The OK button. |
protected javax.swing.JPasswordField |
passwordTextField
The text field representing the password. |
protected javax.swing.JLabel |
retryLabel
The retry label. |
protected javax.swing.JTextField |
usernameTextField
The text field representing the username. |
Constructor Summary | |
---|---|
LoginBeanSwingUtil()
Default constructor. |
|
LoginBeanSwingUtil(com.sas.util.login.LoginBean bean)
Constructor allowing for the specification of a LoginBean |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent evt)
The event handler for the various Swing buttons. |
void |
cancelAction()
Implementation of LoginBeanActionInterface This method is included here to support the testing feature of the main program, and to serve as an example of how to implement this interface. |
void |
closeAction()
Implementation of LoginBeanActionInterface This method is included here to support the testing feature of the main program, and to serve as an example of how to implement this interface. |
javax.swing.JPanel |
createSwingPanel()
Creates a Swing panel from the properties specified on the associated LoginBean. |
void |
failureAction()
Implementation of LoginBeanActionInterface This method is included here to support the testing feature of the main program, and to serve as an example of how to implement this interface. |
com.sas.util.login.LoginBean |
getLoginBean()
Returns the LoginBean instance associated with this class. |
int |
getSelectedButton()
Returns the Swing button selected by the user. |
static void |
main(java.lang.String[] argv)
The main program serves as a testing facility for this class. |
void |
OKAction()
Implementation of LoginBeanActionInterface. |
void |
retryAction()
Implementation of LoginBeanActionInterface This method is included here to support the testing feature of the main program, and to serve as an example of how to implement this interface. |
void |
setLoginBean(com.sas.util.login.LoginBean bean)
Sets the LoginBean associated with this util class. |
void |
showDialog(java.lang.String dialogTitle,
java.awt.Frame owner)
Displays a modal dialog containing a Swing JPanel for the LoginBean associated with the specified instance of LoginBeanSwingUtil. |
static void |
showDialog(java.lang.String dialogTitle,
java.awt.Frame owner,
com.sas.util.login.LoginBean bean)
Displays a modal dialog containing a Swing JPanel for the specified LoginBean. |
void |
successAction()
Implementation of LoginBeanActionInterface This method is included here to support the testing feature of the main program, and to serve as an example of how to implement this interface. |
Field Detail |
---|
protected com.sas.util.login.LoginBean loginBean
protected javax.swing.JTextField usernameTextField
protected javax.swing.JPasswordField passwordTextField
protected javax.swing.JDialog dialog
protected javax.swing.JButton okButton
protected javax.swing.JButton cancelButton
protected javax.swing.JButton closeButton
protected javax.swing.JLabel retryLabel
protected int buttonSelected
Constructor Detail |
---|
public LoginBeanSwingUtil()
public LoginBeanSwingUtil(com.sas.util.login.LoginBean bean)
bean
- An instance of LoginBean associated with this util class.Method Detail |
---|
public void setLoginBean(com.sas.util.login.LoginBean bean)
bean
- An instance of LoginBean to associate with this class.getLoginBean()
public com.sas.util.login.LoginBean getLoginBean()
setLoginBean(LoginBean)
public int getSelectedButton()
public javax.swing.JPanel createSwingPanel()
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
evt
- The ActionEvent.public void OKAction()
OKAction
in interface com.sas.util.login.LoginBeanActionInterface
public void cancelAction()
cancelAction
in interface com.sas.util.login.LoginBeanActionInterface
public void closeAction()
closeAction
in interface com.sas.util.login.LoginBeanActionInterface
public void successAction()
successAction
in interface com.sas.util.login.LoginBeanActionInterface
public void failureAction()
failureAction
in interface com.sas.util.login.LoginBeanActionInterface
public void retryAction()
retryAction
in interface com.sas.util.login.LoginBeanActionInterface
public void showDialog(java.lang.String dialogTitle, java.awt.Frame owner)
dialogTitle
- The title of the dialog window.owner
- The Frame serving as the owner of the dialog.public static void showDialog(java.lang.String dialogTitle, java.awt.Frame owner, com.sas.util.login.LoginBean bean)
dialogTitle
- The title of the dialog window.owner
- The Frame serving as the owner of the dialog.bean
- The login bean to display in the dialog.public static void main(java.lang.String[] argv)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |