import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AtmSystem extends JFrame implements ActionListener
{
private JPanel buttonPanel=new JPanel();
private JPanel area1Panel=new JPanel();
private JPanel area2Panel=new JPanel();
private JTextField note=new JTextField(33);
private JButton buttons[];
private JButton bp1 = new JButton("00");
private JButton bp2 = new JButton("000");
private JButton ok = new JButton("确定");
private JButton exit = new JButton("退出");
private JButton cancel = new JButton("取消");
private JButton change=new JButton("删除");
private JButton getmoney = new JButton("取款");
private JButton search = new JButton("查询余额");
private JButton changekey = new JButton("修改密码");
private JButton putmoney= new JButton("存款");;
private boolean flag0,flag1,flag2,flag3,flag4;//布尔函数,返回对与错
int status=0;//选项 相当于CASE语句
int k,s,k1;//k、s是控制用户名,k1控制密码
String str1="\t欢迎使用中国工商银行ATM柜员机!";
String str2="\t请输入用户名:";
String str3="\t请输入密码:";
String str4="\t请输入取款金额:";
String str5="\t请输入存款金额:";
String str6="\t请输入新密码:";
String str7="\t您的余额为:";
String str8="\t用户名错误,请重新输入:";
String str9="\t密码错误,请重新输入:";
String str10="\t取款金额错误,请重新输入:";
String str11="\t密码修改成功!";
String store1="",store2="";//store1金额 store2存储密码
double moneysum=50000;
double getMoney;
String username="123456";
String password="123456";
public AtmSystem()
{
super("中国工商银行ATM柜员机");
Container container=getContentPane();
buttons=new JButton[10];
change.addActionListener(this);
cancel.addActionListener(this);
ok.addActionListener(this);
exit.addActionListener(this);
changekey.addActionListener(this);
putmoney.addActionListener(this);
getmoney.addActionListener(this);
search.addActionListener(this);
area2Panel.add(changekey);
area2Panel.add(putmoney);
area2Panel.add(getmoney);
area2Panel.add(search);
area2Panel.setLayout(new GridLayout(1,3));
container.add(area2Panel,BorderLayout.NORTH);
note.setText(str1);
note.setEditable(false);
area1Panel.add(note);
buttonPanel.setLayout(new GridLayout(4,4));
for(int count=0;count<buttons.length;count++)
{
buttons[count]=new JButton(""+count);
buttons[count].addActionListener(this);
buttonPanel.add(buttons[count]);
}
buttonPanel.add(bp1);
buttonPanel.add(bp2);
buttonPanel.add(ok);
buttonPanel.add(change);
buttonPanel.add(cancel);
buttonPanel.add(exit);
container.add(buttonPanel,BorderLayout.SOUTH);
container.add(area1Panel);
area1Panel.setVisible(true);
area2Panel.setVisible(false);
setSize(400,250);
setVisible(true);
} public void actionPerformed(ActionEvent event)
{
JButton operation = (JButton) event.getSource();
if(operation==ok)//确认按钮
{
if(status==0)//直接确认,打开登录窗口
{
note.setText(""+str2);//请输入用户名
status=1;
}
else if(flag4==true)//密码正确,进入程序
{
area2Panel.setVisible(true);//一列3行
area1Panel.setVisible(false);//4行4列
flag4=false;//清除FLAG数值
}
else if(status==1&&k==1)//k=1,用户名输入正确,进入输入密码界面
{
note.setText(""+str3);//请输入密码
status=2;
k=0;
}
else if(status==1&&k==0)//k=0,用户名不是指定用户名
{
note.setText(""+str8);//用户名错误,请重新输入
store1="";
}
else if(status==2&&k1==1)//用户名、密码都正确
{
k1=0;//密码判断项清0
area1Panel.setVisible(false);
area2Panel.setVisible(true);
status=3;
}
else if(status==2&&k1==0)//用户名输入正确,密码错误
{
note.setText(""+str9);//密码错误,请重新输入
store2="";
}
else if(status==3)//进入取款界面
{
if(flag0==true)//取款
{
getMoney=Double.valueOf(store1).doubleValue();//取款
if(getMoney<5000&&getMoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag0=false;//flag数值清除
moneysum=moneysum-getMoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
}
else if(flag1==true)//查询余额按钮
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag1=false;
}
else if(flag2==true)//存款按钮
{
putmoney=Double.valueOf(store1).doubleValue();//存款
if(putmoney<5000&&putmoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag2=false;//flag数值清除
moneysum=moneysum+putmoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
}
else if(flag3=true)
{
flag4=true;//修改密码
note.setText(""+str11);//密码修改成功
password=store2;
flag3=false;
}
} }
else if(operation==cancel)//取消按钮
{
if(status==1)
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
status=0;
store1="";
store2="";
}
else if(status==2)
{
note.setText(""+str2);//请输入用户名
status=1;
store1="";
store2="";
}
else if(status==3&&flag2) //存款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag2=false;
store1="";
store2="";
}
else if(status==3&&flag0) //修改密码后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag0=false;
store1="";
store2="";
}
else if(status==3&&flag1) //查询余额后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag1=false;
}
else if(status==3&&flag3) //取款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag3=false;
store1="";
store2="";
}
}
else if(operation==change)//删除按钮
{
if(status==1)//删除用户名
{
note.setText(""+str2);//请输入用户名
store1="";
store2="";
}
else if(status==2)//删除密码
{
note.setText(""+str3);//请输入密码
store1="";
store2="";
}
else if(status==3&&flag2) //删除存款金额
{
note.setText(""+str5);//请输入存款金额
store1="";
store2="";
}
else if(status==3&&flag0) //删除取款金额
{
note.setText(""+str4);//请输入取款金额
store1="";
store2="";
}
else if(status==3&&flag3) //删除密码
{
note.setText(""+str6);//请输入新密码
store1="";
store2="";
}
} else if(operation==getmoney)//取款按钮
{
note.setText(""+str4);//请输入取款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store1="";
flag0=true;//取款按钮
}
else if(operation==search)//查询余额
{
note.setText(""+str7+moneysum);//您的余额为
area2Panel.setVisible(false);
area1Panel.setVisible(true);
flag1=true;//查询余额按钮
}
else if(operation==putmoney)//存款
{
note.setText(""+str5);//请输入存款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
flag2=true;//存款按钮
}
else if(operation==changekey)//修改密码
{
note.setText(""+str6);//请输入新密码
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store2="";
flag3=true;//修改密码按钮
}
else if(operation==exit)//退出
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
area2Panel.setVisible(false);
area1Panel.setVisible(true);
status=0;
flag0=flag1=flag2=flag3=flag4=false;
store1="";
store2="";
k=k1=s=0;
} else if(status==1||(status==3&&flag0==true)) //取款输入
{
for(int count=0;count<buttons.length;count++)
if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1+=event.getActionCommand();
}
user(store1);
}
else if(status==1||(status==3&&flag2==true)) //存款输入
{
for(int count=0;count<buttons.length;count++)
if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1=event.getActionCommand();
}
user(store1);
}
else if(status==2||(status==3&&flag3==true)) //修改密码
{
for(int count=0;count<buttons.length;count++)
if (operation==buttons[count])
{
note.setText(note.getText()+ "*");
store2+=event.getActionCommand();
}
key(store2);
} }
public void user(String load)
{
if(username.equals(load))
{
k=1;//调用用户名正确
s=1;
}
}
public void key(String load)
{
if(password.equals(store2))
{
k1=1;//调用密码正确
}
}
public static void main(String args[])
{
AtmSystem application=new AtmSystem();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.event.*;
import javax.swing.*;
public class AtmSystem extends JFrame implements ActionListener
{
private JPanel buttonPanel=new JPanel();
private JPanel area1Panel=new JPanel();
private JPanel area2Panel=new JPanel();
private JTextField note=new JTextField(33);
private JButton buttons[];
private JButton bp1 = new JButton("00");
private JButton bp2 = new JButton("000");
private JButton ok = new JButton("确定");
private JButton exit = new JButton("退出");
private JButton cancel = new JButton("取消");
private JButton change=new JButton("删除");
private JButton getmoney = new JButton("取款");
private JButton search = new JButton("查询余额");
private JButton changekey = new JButton("修改密码");
private JButton putmoney= new JButton("存款");;
private boolean flag0,flag1,flag2,flag3,flag4;//布尔函数,返回对与错
int status=0;//选项 相当于CASE语句
int k,s,k1;//k、s是控制用户名,k1控制密码
String str1="\t欢迎使用中国工商银行ATM柜员机!";
String str2="\t请输入用户名:";
String str3="\t请输入密码:";
String str4="\t请输入取款金额:";
String str5="\t请输入存款金额:";
String str6="\t请输入新密码:";
String str7="\t您的余额为:";
String str8="\t用户名错误,请重新输入:";
String str9="\t密码错误,请重新输入:";
String str10="\t取款金额错误,请重新输入:";
String str11="\t密码修改成功!";
String store1="",store2="";//store1金额 store2存储密码
double moneysum=50000;
double getMoney;
String username="123456";
String password="123456";
public AtmSystem()
{
super("中国工商银行ATM柜员机");
Container container=getContentPane();
buttons=new JButton[10];
change.addActionListener(this);
cancel.addActionListener(this);
ok.addActionListener(this);
exit.addActionListener(this);
changekey.addActionListener(this);
putmoney.addActionListener(this);
getmoney.addActionListener(this);
search.addActionListener(this);
area2Panel.add(changekey);
area2Panel.add(putmoney);
area2Panel.add(getmoney);
area2Panel.add(search);
area2Panel.setLayout(new GridLayout(1,3));
container.add(area2Panel,BorderLayout.NORTH);
note.setText(str1);
note.setEditable(false);
area1Panel.add(note);
buttonPanel.setLayout(new GridLayout(4,4));
for(int count=0;count<buttons.length;count++)
{
buttons[count]=new JButton(""+count);
buttons[count].addActionListener(this);
buttonPanel.add(buttons[count]);
}
buttonPanel.add(bp1);
buttonPanel.add(bp2);
buttonPanel.add(ok);
buttonPanel.add(change);
buttonPanel.add(cancel);
buttonPanel.add(exit);
container.add(buttonPanel,BorderLayout.SOUTH);
container.add(area1Panel);
area1Panel.setVisible(true);
area2Panel.setVisible(false);
setSize(400,250);
setVisible(true);
} public void actionPerformed(ActionEvent event)
{
JButton operation = (JButton) event.getSource();
if(operation==ok)//确认按钮
{
if(status==0)//直接确认,打开登录窗口
{
note.setText(""+str2);//请输入用户名
status=1;
}
else if(flag4==true)//密码正确,进入程序
{
area2Panel.setVisible(true);//一列3行
area1Panel.setVisible(false);//4行4列
flag4=false;//清除FLAG数值
}
else if(status==1&&k==1)//k=1,用户名输入正确,进入输入密码界面
{
note.setText(""+str3);//请输入密码
status=2;
k=0;
}
else if(status==1&&k==0)//k=0,用户名不是指定用户名
{
note.setText(""+str8);//用户名错误,请重新输入
store1="";
}
else if(status==2&&k1==1)//用户名、密码都正确
{
k1=0;//密码判断项清0
area1Panel.setVisible(false);
area2Panel.setVisible(true);
status=3;
}
else if(status==2&&k1==0)//用户名输入正确,密码错误
{
note.setText(""+str9);//密码错误,请重新输入
store2="";
}
else if(status==3)//进入取款界面
{
if(flag0==true)//取款
{
getMoney=Double.valueOf(store1).doubleValue();//取款
if(getMoney<5000&&getMoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag0=false;//flag数值清除
moneysum=moneysum-getMoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
}
else if(flag1==true)//查询余额按钮
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag1=false;
}
else if(flag2==true)//存款按钮
{
putmoney=Double.valueOf(store1).doubleValue();//存款
if(putmoney<5000&&putmoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag2=false;//flag数值清除
moneysum=moneysum+putmoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
}
else if(flag3=true)
{
flag4=true;//修改密码
note.setText(""+str11);//密码修改成功
password=store2;
flag3=false;
}
} }
else if(operation==cancel)//取消按钮
{
if(status==1)
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
status=0;
store1="";
store2="";
}
else if(status==2)
{
note.setText(""+str2);//请输入用户名
status=1;
store1="";
store2="";
}
else if(status==3&&flag2) //存款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag2=false;
store1="";
store2="";
}
else if(status==3&&flag0) //修改密码后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag0=false;
store1="";
store2="";
}
else if(status==3&&flag1) //查询余额后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag1=false;
}
else if(status==3&&flag3) //取款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag3=false;
store1="";
store2="";
}
}
else if(operation==change)//删除按钮
{
if(status==1)//删除用户名
{
note.setText(""+str2);//请输入用户名
store1="";
store2="";
}
else if(status==2)//删除密码
{
note.setText(""+str3);//请输入密码
store1="";
store2="";
}
else if(status==3&&flag2) //删除存款金额
{
note.setText(""+str5);//请输入存款金额
store1="";
store2="";
}
else if(status==3&&flag0) //删除取款金额
{
note.setText(""+str4);//请输入取款金额
store1="";
store2="";
}
else if(status==3&&flag3) //删除密码
{
note.setText(""+str6);//请输入新密码
store1="";
store2="";
}
} else if(operation==getmoney)//取款按钮
{
note.setText(""+str4);//请输入取款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store1="";
flag0=true;//取款按钮
}
else if(operation==search)//查询余额
{
note.setText(""+str7+moneysum);//您的余额为
area2Panel.setVisible(false);
area1Panel.setVisible(true);
flag1=true;//查询余额按钮
}
else if(operation==putmoney)//存款
{
note.setText(""+str5);//请输入存款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
flag2=true;//存款按钮
}
else if(operation==changekey)//修改密码
{
note.setText(""+str6);//请输入新密码
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store2="";
flag3=true;//修改密码按钮
}
else if(operation==exit)//退出
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
area2Panel.setVisible(false);
area1Panel.setVisible(true);
status=0;
flag0=flag1=flag2=flag3=flag4=false;
store1="";
store2="";
k=k1=s=0;
} else if(status==1||(status==3&&flag0==true)) //取款输入
{
for(int count=0;count<buttons.length;count++)
if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1+=event.getActionCommand();
}
user(store1);
}
else if(status==1||(status==3&&flag2==true)) //存款输入
{
for(int count=0;count<buttons.length;count++)
if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1=event.getActionCommand();
}
user(store1);
}
else if(status==2||(status==3&&flag3==true)) //修改密码
{
for(int count=0;count<buttons.length;count++)
if (operation==buttons[count])
{
note.setText(note.getText()+ "*");
store2+=event.getActionCommand();
}
key(store2);
} }
public void user(String load)
{
if(username.equals(load))
{
k=1;//调用用户名正确
s=1;
}
}
public void key(String load)
{
if(password.equals(store2))
{
k1=1;//调用密码正确
}
}
public static void main(String args[])
{
AtmSystem application=new AtmSystem();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
{
Double putmoney=Double.valueOf(store1).doubleValue();//存款
……这里加Double就OK啦
import java.awt.event.*;
import javax.swing.*;
public class AtmSystem extends JFrame implements ActionListener
{
private JPanel buttonPanel=new JPanel();
private JPanel area1Panel=new JPanel();
private JPanel area2Panel=new JPanel();
private JTextField note=new JTextField(33);
private JButton buttons[];
private JButton bp1 = new JButton("00");
private JButton bp2 = new JButton("000");
private JButton ok = new JButton("确定");
private JButton exit = new JButton("退出");
private JButton cancel = new JButton("取消");
private JButton change=new JButton("删除");
private JButton getmoney = new JButton("取款");
private JButton search = new JButton("查询余额");
private JButton changekey = new JButton("修改密码");
private JButton putmoney= new JButton("存款");;
private boolean flag0,flag1,flag2,flag3,flag4;//布尔函数,返回对与错
int status=0;//选项 相当于CASE语句
int k,s,k1;//k、s是控制用户名,k1控制密码
String str1="\t欢迎使用中国工商银行ATM柜员机!";
String str2="\t请输入用户名:";
String str3="\t请输入密码:";
String str4="\t请输入取款金额:";
String str5="\t请输入存款金额:";
String str6="\t请输入新密码:";
String str7="\t您的余额为:";
String str8="\t用户名错误,请重新输入:";
String str9="\t密码错误,请重新输入:";
String str10="\t取款金额错误,请重新输入:";
String str11="\t密码修改成功!";
String store1="",store2="";//store1金额 store2存储密码
double moneysum=50000;
double getMoney;
double putMoney;
String username="123456";
String password="123456";
public AtmSystem()
{
super("中国工商银行ATM柜员机");
Container container=getContentPane();
buttons=new JButton[10];
change.addActionListener(this);
cancel.addActionListener(this);
ok.addActionListener(this);
exit.addActionListener(this);
changekey.addActionListener(this);
putmoney.addActionListener(this);
getmoney.addActionListener(this);
search.addActionListener(this);
area2Panel.add(changekey);
area2Panel.add(putmoney);
area2Panel.add(getmoney);
area2Panel.add(search);
area2Panel.setLayout(new GridLayout(1,3));
container.add(area2Panel,BorderLayout.NORTH);
note.setText(str1);
note.setEditable(false);
area1Panel.add(note);
buttonPanel.setLayout(new GridLayout(4,4));
for(int count=0;count<buttons.length;count++)
{
buttons[count]=new JButton(""+count);
buttons[count].addActionListener(this);
buttonPanel.add(buttons[count]); }
buttonPanel.add(bp1);
buttonPanel.add(bp2);
buttonPanel.add(ok);
buttonPanel.add(change);
buttonPanel.add(cancel);
buttonPanel.add(exit);
container.add(buttonPanel,BorderLayout.SOUTH);
container.add(area1Panel);
area1Panel.setVisible(true);
area2Panel.setVisible(false);
setSize(400,250);
setVisible(true);
} public void actionPerformed(ActionEvent event)
{
JButton operation = (JButton) event.getSource();
if(operation==ok)//确认按钮
{
if(status==0)//直接确认,打开登录窗口
{
note.setText(""+str2);//请输入用户名
status=1;
}
else if(flag4==true)//密码正确,进入程序
{
area2Panel.setVisible(true);//一列3行
area1Panel.setVisible(false);//4行4列
flag4=false;//清除FLAG数值
}
else if(status==1&&k==1)//k=1,用户名输入正确,进入输入密码界面
{
note.setText(""+str3);//请输入密码
status=2;
k=0;
}
else if(status==1&&k==0)//k=0,用户名不是指定用户名
{
note.setText(""+str8);//用户名错误,请重新输入
store1="";
}
else if(status==2&&k1==1)//用户名、密码都正确
{
k1=0;//密码判断项清0
area1Panel.setVisible(false);
area2Panel.setVisible(true);
status=3;
}
else if(status==2&&k1==0)//用户名输入正确,密码错误
{
note.setText(""+str9);//密码错误,请重新输入
store2="";
}
else if(status==3)//进入取款界面
{
if(flag0==true)//取款
{ getMoney=Double.valueOf(store1).doubleValue();//取款
if(getMoney<5000&&getMoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag0=false;//flag数值清除
moneysum=moneysum-getMoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
}
else if(flag1==true)//查询余额按钮
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag1=false;
}
else if(flag2==true)//存款按钮
{
putMoney=Double.valueOf(store1).doubleValue();//存款
if(putMoney<5000&&putMoney%100==0)
{
area2Panel.setVisible(true);
area1Panel.setVisible(false);
flag2=false;//flag数值清除
moneysum=moneysum+putMoney;
}
else
{
area2Panel.setVisible(false);
area1Panel.setVisible(true);
note.setText(""+str10);//错误,请重新输入
store1="";
}
} else if(flag3=true)
{
flag4=true;//修改密码
note.setText(""+str11);//密码修改成功
password=store2;
flag3=false;
}
} }
else if(operation==cancel)//取消按钮
{
if(status==1)
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
status=0;
store1="";
store2="";
}
else if(status==2)
{
note.setText(""+str2);//请输入用户名
status=1;
store1="";
store2="";
}
else if(status==3&&flag2) //存款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag2=false;
store1="";
store2="";
}
else if(status==3&&flag0) //修改密码后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag0=false;
store1="";
store2="";
}
else if(status==3&&flag1) //查询余额后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag1=false;
}
else if(status==3&&flag3) //取款后返回操作界面
{
area1Panel.setVisible(false);
area2Panel.setVisible(true);
flag3=false;
store1="";
store2="";
}
}
else if(operation==change)//删除按钮
{
if(status==1)//删除用户名
{
note.setText(""+str2);//请输入用户名
store1="";
store2="";
}
else if(status==2)//删除密码
{
note.setText(""+str3);//请输入密码
store1="";
store2="";
}
else if(status==3&&flag2) //删除存款金额
{
note.setText(""+str5);//请输入存款金额
store1="";
store2="";
}
else if(status==3&&flag0) //删除取款金额
{
note.setText(""+str4);//请输入取款金额
store1="";
store2="";
} else if(status==3&&flag3) //删除密码
{
note.setText(""+str6);//请输入新密码
store1="";
store2="";
}
} else if(operation==getmoney)//取款按钮
{
note.setText(""+str4);//请输入取款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store1="";
flag0=true;//取款按钮
}
else if(operation==search)//查询余额
{
note.setText(""+str7+moneysum);//您的余额为
area2Panel.setVisible(false);
area1Panel.setVisible(true);
flag1=true;//查询余额按钮
}
else if(operation==putmoney)//存款
{
note.setText(""+str5);//请输入存款金额
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store1="";
flag2=true;//存款按钮
}
else if(operation==changekey)//修改密码
{
note.setText(""+str6);//请输入新密码
area2Panel.setVisible(false);
area1Panel.setVisible(true);
store2="";
flag3=true;//修改密码按钮
}
else if(operation==exit)//退出
{
note.setText(""+str1);//欢迎使用中国工商银行ATM柜员机
area2Panel.setVisible(false);
area1Panel.setVisible(true);
status=0;
flag0=flag1=flag2=flag3=flag4=false;
store1="";
store2="";
k=k1=s=0;
} else if(status==1||(status==3&&flag0==true)) //取款输入
{
for(int count=0;count<buttons.length;count++) if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1+=event.getActionCommand(); } user(store1);
} else if(status==1||(status==3&&flag2==true)) //存款输入
{
for(int count=0;count<buttons.length;count++) if (operation== buttons[count])
{
note.setText(note.getText() + count);
store1+=event.getActionCommand(); } user(store1); }
else if(status==2||(status==3&&flag3==true)) //修改密码
{
for(int count=0;count<buttons.length;count++) if (operation==buttons[count])
{
note.setText(note.getText()+ "*");
store2+=event.getActionCommand();
}
key(store2);
} }
public void user(String load)
{ if(username.equals(load))
{
k=1;//调用用户名正确
s=1;
} }
public void key(String load)
{
if(password.equals(store2))
{
k1=1;//调用密码正确
} }
public static void main(String args[])
{
AtmSystem application=new AtmSystem();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}