ATM system implementation [2]--Password Modification window [00 original]
Last Update:2018-07-23
Source: Internet
Author: User
Package cn.edu.ynu.sei.atm.client.ui;
Import cn.edu.ynu.sei.atm.interfaceDef.IVerification;
Import Com.swtdesigner.SWTResourceManager;
Import java.rmi.Naming;
Import java.rmi.RemoteException;
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.events.MouseAdapter;
Import org.eclipse.swt.events.MouseEvent;
Import Org.eclipse.swt.widgets.Composite;
Import Org.eclipse.swt.widgets.Label;
Import Org.eclipse.swt.widgets.MessageBox;
/**
* Modify Password Window container
* @author 88250
*/
public class Changepwdcomposite extends composite
{
/**
* Back button
*/
Private Label Returnlbl;
/**
* Verify Status Display label
*/
Private Label Verifystateshowlbl;
/**
* Prompt Validation Status label
*/
Private Label Verifystatelbl;
/**
* Prompt to enter old password label
*/
Private Label Pleaseinputoldpwdlbl;
/**
* Password Verification panel container
*/
Private pwdinputcomposite pic = null;
/**
* Save Confirmation password cache when changing password
*/
Private String pwdbuf = null;
/**
* Parent Window Container
*/
Private composite parent = NULL;
/**
* Verify Identity interface instance
*/
Private iverification verification = null;
/**
* Create modify Password window container
* @param parent window Container
*/
Public Changepwdcomposite (composite parent)
{
Super (parent, SWT. NONE);
this. Parent = parent;
Createcontents ();
}
/**
* Get the return button
* @return Return button
*/
Public Label getreturnbtn ()
{
return RETURNLBL;
}
/**
* Create modify Password window container containing controls
*/
private void Createcontents ()
{
PLEASEINPUTOLDPWDLBL = new Label (this, SWT. NONE);
Pleaseinputoldpwdlbl.settext ("Please enter old password:");
Pleaseinputoldpwdlbl.setbounds (10, 10, 141, 20);
pic = new Pwdinputcomposite (this);
Pic.setbounds (70, 35, 294, 185);
OK button to monitor when entering old password
PIC.GETCONFIRMLBL (). Addmouselistener (New Mouseadapter ()
{
public void MouseDown (MouseEvent arg0)
{
Get remote Service object
Try
{
Verification = (iverification) naming
. lookup (Logininterface.serviceaddr + "verification");
}
catch (RemoteException re)
{
MessageBox Exitdlg = new MessageBox (Parent.getshell ());
Exitdlg.settext ("Network connectivity problem ....") " );
Exitdlg.setmessage ("Cannot connect to the server, the system will exit.") " );
Exitdlg.open ();
System.exit (0);
Re.printstacktrace ();
}
catch (Exception e)
{
E.printstacktrace ();
}
if (Pleaseinputoldpwdlbl.gettext (). Equals ("Please enter old password:")
{//Confirm old password
Try
{
if (Verification.verify (Logininterface.logincardid,
Pic.getpwdtext ()))
{//Verify Success
Verifystateshowlbl.settext ("The password is correct.) " );
Pleaseinputoldpwdlbl.settext ("Please enter a new password:");
Pic.clearpwdtext ();
}
Else
{//validation failed
Verifystateshowlbl.settext ("Bad password"). " );
}
}
catch (RemoteException re)
{
MessageBox Exitdlg = new MessageBox (Parent.getshell ());
Exitdlg.settext ("Network connectivity problem ....") " );
Exitdlg.setmessage ("Cannot connect to the server, the system will exit.") " );
Exitdlg.open ();
System.exit (0);
Re.printstacktrace ();
}
catch (Exception e)
{
E.printstacktrace ();
}
}
else if (Pleaseinputoldpwdlbl.gettext (). Equals ("Please enter a new password:")
{//Enter new password
Pwdbuf = Pic.getpwdtext ();
Pleaseinputoldpwdlbl.settext ("Please enter new password again:");
Pic.clearpwdtext ();
}
Else
{//change to new password
Try
{
if (Pic.getpwdtext (). Equals (PWDBUF))
{
Verification.changepwd (
Logininterface.logincardid, PWDBUF);
Verifystateshowlbl.settext ("Modify password succeeded.) " );
}
Else
{
Verifystateshowlbl.settext ("Two input passwords are inconsistent.) " );
Pic.clearpwdtext ();
}
}
catch (RemoteException re)
{
MessageBox Exitdlg = new MessageBox (Parent.getshell ());
Exitdlg.settext ("Network connectivity problem ....") " );
Exitdlg.setmessage ("Cannot connect to the server, the system will exit.") " );
Exitdlg.open ();
System.exit (0);
Re.printstacktrace ();
}
catch (Exception e)
{
E.printstacktrace ();
}
}
}
});
VERIFYSTATELBL = new Label (this, SWT. NONE);
Verifystatelbl.settext ("state:");
Verifystatelbl.setbounds (41, 225, 40, 20);
VERIFYSTATESHOWLBL = new Label (this, SWT. NONE);
Verifystateshowlbl.setbounds (83, 227, 100, 20);
RETURNLBL = new Label (this, SWT. BORDER);
Returnlbl.setbackgroundimage (Swtresourcemanager.getimage (
Changepwdcomposite. Class, "Selectserviceimages/return. JPG "));
Returnlbl.setbounds (200, 9, 82, 17);
}
public void setvisible (Boolean b)
{
ClearHistory ();
Super. setvisible (b);
}
/**
* Erase the user's history action record
*/
private void ClearHistory ()
{
Pleaseinputoldpwdlbl.settext ("Please enter old password:");
Pic.clearpwdtext ();
Verifystateshowlbl.settext ("");
}