ATM柜员机模拟程序
要求使用图形用户界面:
1、通过主界面,可以进入管理员界面、用户界面、系统设置界面、退出;
2、启动软件,可以进入用户模式,也可以进入系统管理模式;
3、进入系统管理模式,需要输入管理员账号和密码,可以查看这台ATM机近期资金出入明细,可以查看这台ATM机上面操作的所有账户的历史记录和明细;
4、进入用户账号和密码的登录界面,当输入给定的卡号和密码(初始卡号16位和密码6位)时,对比系统存储的账号和密码正确,能登录ATM柜员机系统,当日出错次数操作3次,当日锁定账户不能继续操作,累计三日被锁定,需要管理员账号才能够完成解锁操作。
用户可以按照以下规则进行操作:
1、查询余额:初始余额为100000元;
2、ATM取款:每次取款金额为100的倍数,总额不超过5000元,支取金额不允许透支;
3、ATM存款:不能出现负存款,要求存钱为100的整数倍;
4、ATM转账:通过登录的用户向指定的银行账号(在系统中已经保存)转账,若银行卡不存在,则提
示银行卡号输入错误,转账成功则提示“转账成功”,并且工具日期能够实现当日转账金额的限制;
5、历史交易记录查询,要求能够保存20条以上的交易记录;
6、修改密码:新密码长度不小于6位,不允许出现6位完全相同的情况,只有旧密码正确,新密码符合要求,且两次输入相同的情况下才可以成功修改密码;
7、退卡:点击退卡,返回登录界面。
主界面
//文件名:MainInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public abstract class MainInterface implements ActionListener {
static JFrame mainJFrame=new JFrame();
static JLabel lbl=new JLabel("ATM柜员机模拟程序——主界面",JLabel.CENTER);
static JButton bt_userMode=new JButton("用户模式");
static JButton bt_systemManagementMode=new JButton("系统管理模式");
static JButton bt_signOut=new JButton("退出");
public static void main(String[] args) {
// TODO Auto-generated method stub
mainJFrame.setTitle("ATM柜员机模拟程序——主界面");
mainJFrame.setBounds(0, 0, 800, 600);
mainJFrame.setLocationRelativeTo(null);
mainJFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container container=mainJFrame.getContentPane();
container.setLayout(null);
container.add(lbl);
lbl.setBounds(0, 75, 800, 50);
lbl.setFont(new Font("楷体",Font.BOLD,40));
container.add(bt_userMode);
bt_userMode.setBounds(300, 200, 200, 50);
bt_userMode.setFont(new Font("黑体",Font.BOLD,20));
bt_userMode.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_userMode) {
new UserLoginInterface().main(args);
}
}
});
container.add(bt_systemManagementMode);
bt_systemManagementMode.setBounds(300, 300, 200, 50);
bt_systemManagementMode.setFont(new Font("黑体",Font.BOLD,20));
bt_systemManagementMode.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_systemManagementMode) {
new SystemSettingInterface().main(args);
}
}
});
container.add(bt_signOut);
bt_signOut.setBounds(300, 400, 200, 50);
bt_signOut.setFont(new Font("黑体",Font.BOLD,20));
bt_signOut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_signOut) {
mainJFrame.dispose();
System.exit(0);
}
}
});
mainJFrame.setVisible(true);
}
}
用户登录界面——测试账号:6214837525982959,密码:123456
//文件名:UserLoginInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class UserLoginInterface {
static JFrame mainJFrame_1=new JFrame();
static JLabel lbl=new JLabel("ATM柜员机模拟程序——用户登录界面",JLabel.CENTER);
static JDialog diag_message=new JDialog();
static JLabel lb_message=new JLabel();
static JLabel lb_name=new JLabel("账号");
static JLabel lb_pass=new JLabel("密码");
static JTextField tf_name=new JTextField();
static JPasswordField pf_pass=new JPasswordField();
static JButton bt_login=new JButton("登录");
static JButton bt_reset=new JButton("重置");
static JButton bt_return=new JButton("返回");
public static void main(String[] args) {
// TODO Auto-generated method stub
mainJFrame_1.setTitle("ATM柜员机模拟程序——用户登录界面");
mainJFrame_1.setBounds(0, 0, 800, 600);
mainJFrame_1.setLocationRelativeTo(null);
mainJFrame_1.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container container=mainJFrame_1.getContentPane();
container.setLayout(null);
container.add(lbl);
lbl.setBounds(0, 75, 800, 50);
lbl.setFont(new Font("楷体",Font.BOLD,40));
diag_message.setTitle("消息");
diag_message.setSize(800, 600);
diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
diag_message.add(lb_message);
diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
container.add(lb_name);
lb_name.setBounds(250, 200, 50, 50);
lb_name.setFont(new Font("黑体",Font.BOLD,20));
container.add(lb_pass);
lb_pass.setBounds(250, 300, 50, 50);
lb_pass.setFont(new Font("黑体",Font.BOLD,20));
container.add(tf_name);
tf_name.setBounds(350, 200, 200, 50);
tf_name.setFont(new Font("黑体",Font.BOLD,20));
container.add(pf_pass);
pf_pass.setBounds(350, 300, 200, 50);
pf_pass.setFont(new Font("黑体",Font.BOLD,20));
pf_pass.setEchoChar('*');
container.add(bt_login);
bt_login.setBounds(250, 400, 100, 50);
bt_login.setFont(new Font("黑体",Font.BOLD,20));
bt_login.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_login) {
if((tf_name.getText()).equals("6214837525982959")&&(String.valueOf(pf_pass.getPassword())).equals("123456")) {
tf_name.setText("");
pf_pass.setText("");
new UserInterface().main(args);
}
else {
tf_name.setText("");
pf_pass.setText("");
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
lb_message.setText("请注意:您输入的账号或密码有误,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
}
});
container.add(bt_reset);
bt_reset.setBounds(450, 400, 100, 50);
bt_reset.setFont(new Font("黑体",Font.BOLD,20));
bt_reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_reset) {
tf_name.setText("");
pf_pass.setText("");
}
}
});
container.add(bt_return);
bt_return.setBounds(350, 500, 100, 50);
bt_return.setFont(new Font("黑体",Font.BOLD,20));
bt_return.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return) {
mainJFrame_1.dispose();
}
}
});
mainJFrame_1.setVisible(true);
}
}
系统设置界面——测试帐号与密码:000000
//文件名:SystemSettingInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SystemSettingInterface {
static JFrame mainJFrame_2=new JFrame();
static JLabel lbl=new JLabel("ATM柜员机模拟程序——系统设置界面",JLabel.CENTER);
static JDialog diag_message=new JDialog();
static JLabel lb_message=new JLabel();
static JLabel lb_name=new JLabel("帐号");
static JLabel lb_pass=new JLabel("密码");
static JTextField tf_name=new JTextField();
static JPasswordField pf_pass=new JPasswordField();
static JButton bt_login=new JButton("登录");
static JButton bt_reset=new JButton("重置");
static JButton bt_return=new JButton("返回");
public static void main(String[] args) {
// TODO Auto-generated method stub
mainJFrame_2.setTitle("ATM柜员机模拟程序——系统设置界面");
mainJFrame_2.setBounds(0, 0, 800, 600);
mainJFrame_2.setLocationRelativeTo(null);
mainJFrame_2.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container container=mainJFrame_2.getContentPane();
container.setLayout(null);
container.add(lbl);
lbl.setBounds(0, 75, 800, 50);
lbl.setFont(new Font("楷体",Font.BOLD,40));
diag_message.setTitle("消息");
diag_message.setSize(800, 600);
diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
diag_message.add(lb_message);
diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
container.add(lb_name);
lb_name.setBounds(250, 200, 50, 50);
lb_name.setFont(new Font("黑体",Font.BOLD,20));
container.add(lb_pass);
lb_pass.setBounds(250, 300, 50, 50);
lb_pass.setFont(new Font("黑体",Font.BOLD,20));
container.add(tf_name);
tf_name.setBounds(350, 200, 200, 50);
tf_name.setFont(new Font("黑体",Font.BOLD,20));
container.add(pf_pass);
pf_pass.setBounds(350, 300, 200, 50);
pf_pass.setFont(new Font("黑体",Font.BOLD,20));
pf_pass.setEchoChar('*');
container.add(bt_login);
bt_login.setBounds(250, 400, 100, 50);
bt_login.setFont(new Font("黑体",Font.BOLD,20));
bt_login.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_login) {
if((tf_name.getText()).equals("000000")&&(String.valueOf(pf_pass.getPassword())).equals("000000")) {
tf_name.setText("");
pf_pass.setText("");
new AdministratorInterface().main(args);
}
else {
tf_name.setText("");
pf_pass.setText("");
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
lb_message.setText("请注意:您输入的管理员账号或密码有误,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
}
});
container.add(bt_reset);
bt_reset.setBounds(450, 400, 100, 50);
bt_reset.setFont(new Font("黑体",Font.BOLD,20));
bt_reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_reset) {
tf_name.setText("");
pf_pass.setText("");
}
}
});
container.add(bt_return);
bt_return.setBounds(350, 500, 100, 50);
bt_return.setFont(new Font("黑体",Font.BOLD,20));
bt_return.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return) {
mainJFrame_2.dispose();
}
}
});
mainJFrame_2.setVisible(true);
}
}
用户界面
//文件名:UserInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class UserInterface {
//用户界面组件
static JFrame mainJFrame_3=new JFrame();
static JLabel lbl=new JLabel("ATM柜员机模拟程序——用户界面",JLabel.CENTER);
static JDialog diag_message=new JDialog();
static JLabel lb_message=new JLabel();
//查询余额界面组件
static JDialog diag_checkTheBalance=new JDialog(mainJFrame_3);
static JLabel lb_checkTheBalance=new JLabel();
static JButton bt_return_checkTheBalance=new JButton("返回");
//取款界面组件
static JDialog diag_withdrawMoney=new JDialog(mainJFrame_3);
static JLabel lb_withdrawMoney=new JLabel();
static JTextField tf_withdrawMoney=new JTextField(20);
static JButton bt_determine_withdrawMoney=new JButton("确定");
static JButton bt_return_withdrawMoney=new JButton("返回");
//存款界面组件
static JDialog diag_deposit=new JDialog(mainJFrame_3);
static JLabel lb_deposit=new JLabel();
static JTextField tf_deposit=new JTextField(20);
static JButton bt_determine_deposit=new JButton("确定");
static JButton bt_return_deposit=new JButton("返回");
//转账界面组件
static JDialog diag_transferAccounts=new JDialog(mainJFrame_3);
static JLabel lb_transferAccounts=new JLabel();
static JTextField tf_transferAccounts_name=new JTextField(20);
static JTextField tf_transferAccounts_amount=new JTextField(20);
static JButton bt_determine_transferAccounts=new JButton("确定");
static JButton bt_return_transferAccounts=new JButton("返回");
//转账确认界面组件
static JDialog diag_transferAccounts_confirm=new JDialog(mainJFrame_3);
static JLabel lb_transferAccounts_confirm_name=new JLabel();
static JLabel lb_transferAccounts_confirm_amount=new JLabel();
static JButton bt_transferAccounts_confirm_yes=new JButton("是");
static JButton bt_transferAccounts_confirm_no=new JButton("否");
//历史交易记录查询界面组件
static JDialog diag_historicalTransactionQuery=new JDialog(mainJFrame_3);
static JScrollPane sp=new JScrollPane();
static JButton bt_return_historicalTransactionQuery=new JButton("返回");
//修改密码界面组件
static JDialog diag_changePassword=new JDialog(mainJFrame_3);
static JTextField tf_changePassword_old=new JTextField(20);
static JTextField tf_changePassword_new=new JTextField(20);
static JTextField tf_changePassword_new_confirm=new JTextField(20);
static JButton bt_determine_changePassword=new JButton("确定");
static JButton bt_return_changePassword=new JButton("返回");
//退卡界面组件
static JDialog diag_refundCard=new JDialog(mainJFrame_3);
static JButton bt_close=new JButton("关闭");
static JButton bt_cancel=new JButton("取消");
//用户界面组件
static JButton bt_checkTheBalance=new JButton("查询余额");
static JButton bt_withdrawMoney=new JButton("取款");
static JButton bt_deposit=new JButton("存款");
static JButton bt_transferAccounts=new JButton("转账");
static JButton bt_historicalTransactionQuery=new JButton("历史交易记录查询");
static JButton bt_changePassword=new JButton("修改密码");
static JButton bt_refundCard=new JButton("退卡");
public static void main(String[] args) {
// TODO Auto-generated method stub
//用户界面
mainJFrame_3.setTitle("ATM柜员机模拟程序——用户界面");
mainJFrame_3.setBounds(0, 0, 800, 600);
mainJFrame_3.setLocationRelativeTo(null);
mainJFrame_3.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container container=mainJFrame_3.getContentPane();
container.setLayout(null);
container.add(lbl);
lbl.setBounds(0, 75, 800, 50);
lbl.setFont(new Font("楷体",Font.BOLD,40));
diag_message.setTitle("消息");
diag_message.setSize(800, 600);
diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
diag_message.add(lb_message);
diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
//查询余额界面
diag_checkTheBalance.setTitle("查询余额");
diag_checkTheBalance.setSize(400, 300);
diag_checkTheBalance.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
diag_checkTheBalance.add(lb_checkTheBalance);
lb_checkTheBalance.setText("您的余额为 100,000 元");
lb_checkTheBalance.setFont(new Font("楷体",Font.BOLD,20));
diag_checkTheBalance.add(bt_return_checkTheBalance);
bt_return_checkTheBalance.setFont(new Font("黑体",Font.BOLD,15));
bt_return_checkTheBalance.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_checkTheBalance) {
diag_checkTheBalance.dispose();
}
}
});
container.add(bt_checkTheBalance);
bt_checkTheBalance.setBounds(0, 200, 200, 50);
bt_checkTheBalance.setFont(new Font("黑体",Font.BOLD,20));
bt_checkTheBalance.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_checkTheBalance) {
diag_checkTheBalance.setLocationRelativeTo(null);
diag_checkTheBalance.setVisible(true);
}
}
});
//取款界面
diag_withdrawMoney.setTitle("取款");
diag_withdrawMoney.setSize(400, 300);
diag_withdrawMoney.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
diag_withdrawMoney.add(lb_withdrawMoney);
lb_withdrawMoney.setText("您的余额为 100,000 元");
lb_withdrawMoney.setFont(new Font("楷体",Font.BOLD,20));
diag_withdrawMoney.add(tf_withdrawMoney);
tf_withdrawMoney.setText("请输入取款金额");
tf_withdrawMoney.setFont(new Font("楷体",Font.BOLD,20));
diag_withdrawMoney.add(bt_determine_withdrawMoney);
bt_determine_withdrawMoney.setFont(new Font("黑体",Font.BOLD,15));
bt_determine_withdrawMoney.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_determine_withdrawMoney) {
tf_withdrawMoney.setText("请输入取款金额");
diag_withdrawMoney.dispose();
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
lb_message.setText("请注意:取款成功!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
});
diag_withdrawMoney.add(bt_return_withdrawMoney);
bt_return_withdrawMoney.setFont(new Font("黑体",Font.BOLD,15));
bt_return_withdrawMoney.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_withdrawMoney) {
tf_withdrawMoney.setText("请输入取款金额");
diag_withdrawMoney.dispose();
}
}
});
container.add(bt_withdrawMoney);
bt_withdrawMoney.setBounds(0, 300, 200, 50);
bt_withdrawMoney.setFont(new Font("黑体",Font.BOLD,20));
bt_withdrawMoney.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_withdrawMoney) {
diag_withdrawMoney.setLocationRelativeTo(null);
diag_withdrawMoney.setVisible(true);
}
}
});
//存款界面
diag_deposit.setTitle("存款");
diag_deposit.setSize(400, 300);
diag_deposit.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
diag_deposit.add(lb_deposit);
lb_deposit.setText("您的余额为 100,000 元");
lb_deposit.setFont(new Font("楷体",Font.BOLD,20));
diag_deposit.add(tf_deposit);
tf_deposit.setText("请输入存款金额");
tf_deposit.setFont(new Font("楷体",Font.BOLD,20));
diag_deposit.add(bt_determine_deposit);
bt_determine_deposit.setFont(new Font("黑体",Font.BOLD,15));
bt_determine_deposit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_determine_deposit) {
tf_deposit.setText("请输入存款金额");
diag_deposit.dispose();
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
lb_message.setText("请注意:存款成功!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
});
diag_deposit.add(bt_return_deposit);
bt_return_deposit.setFont(new Font("黑体",Font.BOLD,15));
bt_return_deposit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_deposit) {
tf_deposit.setText("请输入存款金额");
diag_deposit.dispose();
}
}
});
container.add(bt_deposit);
bt_deposit.setBounds(0, 400, 200, 50);
bt_deposit.setFont(new Font("黑体",Font.BOLD,20));
bt_deposit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_deposit) {
diag_deposit.setLocationRelativeTo(null);
diag_deposit.setVisible(true);
}
}
});
//转账界面
diag_transferAccounts.setTitle("转账");
diag_transferAccounts.setSize(400, 300);
diag_transferAccounts.setLayout(new FlowLayout(FlowLayout.CENTER,100,25));
diag_transferAccounts.add(lb_transferAccounts);
lb_transferAccounts.setText("您的余额为 100,000 元");
lb_transferAccounts.setFont(new Font("楷体",Font.BOLD,20));
diag_transferAccounts.add(tf_transferAccounts_name);
tf_transferAccounts_name.setText("请输入转账账号");
tf_transferAccounts_name.setFont(new Font("楷体",Font.BOLD,20));
diag_transferAccounts.add(tf_transferAccounts_amount);
tf_transferAccounts_amount.setText("请输入转账金额");
tf_transferAccounts_amount.setFont(new Font("楷体",Font.BOLD,20));
diag_transferAccounts.add(bt_determine_transferAccounts);
bt_determine_transferAccounts.setFont(new Font("黑体",Font.BOLD,15));
bt_determine_transferAccounts.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_determine_transferAccounts) {
diag_transferAccounts_confirm.setLocationRelativeTo(null);
diag_transferAccounts_confirm.setVisible(true);
String amount=tf_transferAccounts_amount.getText();
String name=tf_transferAccounts_name.getText();
lb_transferAccounts_confirm_name.setText("是否确认转账"+ amount +"元");
lb_transferAccounts_confirm_amount.setText("至"+ name +"账户");
}
}
});
diag_transferAccounts.add(bt_return_transferAccounts);
bt_return_transferAccounts.setFont(new Font("黑体",Font.BOLD,15));
bt_return_transferAccounts.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_transferAccounts) {
tf_transferAccounts_name.setText("请输入转账账号");
tf_transferAccounts_amount.setText("请输入转账金额");
diag_transferAccounts.dispose();
}
}
});
container.add(bt_transferAccounts);
bt_transferAccounts.setBounds(0, 500, 200, 50);
bt_transferAccounts.setFont(new Font("黑体",Font.BOLD,20));
bt_transferAccounts.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_transferAccounts) {
diag_transferAccounts.setLocationRelativeTo(null);
diag_transferAccounts.setVisible(true);
}
}
});
//转账确认界面
diag_transferAccounts_confirm.setTitle("转账确认");
diag_transferAccounts_confirm.setSize(400, 300);
diag_transferAccounts_confirm.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
diag_transferAccounts_confirm.add(lb_transferAccounts_confirm_name);
lb_transferAccounts_confirm_name.setFont(new Font("楷体",Font.BOLD,20));
diag_transferAccounts_confirm.add(lb_transferAccounts_confirm_amount);
lb_transferAccounts_confirm_amount.setFont(new Font("楷体",Font.BOLD,20));
diag_transferAccounts_confirm.add(bt_transferAccounts_confirm_yes);
bt_transferAccounts_confirm_yes.setFont(new Font("黑体",Font.BOLD,15));
bt_transferAccounts_confirm_yes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_transferAccounts_confirm_yes) {
tf_transferAccounts_name.setText("请输入转账账号");
tf_transferAccounts_amount.setText("请输入转账金额");
diag_transferAccounts_confirm.dispose();
diag_transferAccounts.dispose();
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
if((tf_transferAccounts_name.getText()).equals("123")) {
lb_message.setText("请注意:转账成功!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
else {
lb_message.setText("请注意:您输入的转账账号有误,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
}
});
diag_transferAccounts_confirm.add(bt_transferAccounts_confirm_no);
bt_transferAccounts_confirm_no.setFont(new Font("黑体",Font.BOLD,15));
bt_transferAccounts_confirm_no.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_transferAccounts_confirm_no) {
tf_transferAccounts_name.setText("请输入转账账号");
tf_transferAccounts_amount.setText("请输入转账金额");
diag_transferAccounts_confirm.dispose();
}
}
});
//历史交易记录查询界面
diag_historicalTransactionQuery.setTitle("历史交易记录查询");
diag_historicalTransactionQuery.setSize(800, 600);
diag_historicalTransactionQuery.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
diag_historicalTransactionQuery.add(sp);
diag_historicalTransactionQuery.add(bt_return_historicalTransactionQuery);
bt_return_historicalTransactionQuery.setFont(new Font("黑体",Font.BOLD,15));
bt_return_historicalTransactionQuery.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_historicalTransactionQuery) {
diag_historicalTransactionQuery.dispose();
}
}
});
container.add(bt_historicalTransactionQuery);
bt_historicalTransactionQuery.setBounds(585, 250, 200, 50);
bt_historicalTransactionQuery.setFont(new Font("黑体",Font.BOLD,19));
bt_historicalTransactionQuery.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_historicalTransactionQuery) {
diag_historicalTransactionQuery.setLocationRelativeTo(null);
diag_historicalTransactionQuery.setVisible(true);
}
}
});
//修改密码界面
diag_changePassword.setTitle("修改密码");
diag_changePassword.setSize(400, 300);
diag_changePassword.setLayout(new FlowLayout(FlowLayout.CENTER,100,25));
diag_changePassword.add(tf_changePassword_old);
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_old.setFont(new Font("楷体",Font.BOLD,20));
diag_changePassword.add(tf_changePassword_new);
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new.setFont(new Font("楷体",Font.BOLD,20));
diag_changePassword.add(tf_changePassword_new_confirm);
tf_changePassword_new_confirm.setText("请确认新密码");
tf_changePassword_new_confirm.setFont(new Font("楷体",Font.BOLD,20));
diag_changePassword.add(bt_determine_changePassword);
bt_determine_changePassword.setFont(new Font("黑体",Font.BOLD,15));
bt_determine_changePassword.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_determine_changePassword) {
diag_changePassword.dispose();
diag_message.setLocationRelativeTo(null);
diag_message.setVisible(true);
String old=tf_changePassword_old.getText();
String new_input=tf_changePassword_new.getText();
String new_confirm=tf_changePassword_new_confirm.getText();
if(!old.equals("请输入旧密码")) {
if(!new_input.equals("请输入新密码")) {
if(!new_confirm.equals("请确认新密码")) {
if(old.equals("123456")) {
if(!new_input.equals(old)) {
if(new_input.length()>=6) {
if(new_input.length()>=6) {//新密码不得出现6位完全相同的数字暂未完善
if(new_confirm.equals(new_input)) {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:修改成功!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:您两次输入的新密码不一致,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:您输入的新密码不得出现6位完全相同的数字,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:您输入的新密码不得少于6位,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:您输入的新密码与旧密码一致,无法修改!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:您输入的旧密码有误,请检查后再试!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:请确认新密码!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:请输入新密码!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
else {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
lb_message.setText("请注意:请输入旧密码!");
lb_message.setFont(new Font("楷体",Font.BOLD,20));
}
}
}
});
diag_changePassword.add(bt_return_changePassword);
bt_return_changePassword.setFont(new Font("黑体",Font.BOLD,15));
bt_return_changePassword.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_changePassword) {
tf_changePassword_old.setText("请输入旧密码");
tf_changePassword_new.setText("请输入新密码");
tf_changePassword_new_confirm.setText("请确认新密码");
diag_changePassword.dispose();
}
}
});
container.add(bt_changePassword);
bt_changePassword.setBounds(585, 350, 200, 50);
bt_changePassword.setFont(new Font("黑体",Font.BOLD,20));
bt_changePassword.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_changePassword) {
diag_changePassword.setLocationRelativeTo(null);
diag_changePassword.setVisible(true);
}
}
});
//退卡界面
diag_refundCard.setTitle("退卡");
diag_refundCard.setSize(400, 300);
diag_refundCard.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
diag_refundCard.add(bt_close);
bt_close.setFont(new Font("黑体",Font.BOLD,15));
bt_close.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_close) {
diag_refundCard.dispose();
mainJFrame_3.dispose();
new UserLoginInterface().main(args);
}
}
});
diag_refundCard.add(bt_cancel);
bt_cancel.setFont(new Font("黑体",Font.BOLD,15));
bt_cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_cancel) {
diag_refundCard.dispose();
}
}
});
container.add(bt_refundCard);
bt_refundCard.setBounds(585, 450, 200, 50);
bt_refundCard.setFont(new Font("黑体",Font.BOLD,20));
bt_refundCard.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_refundCard) {
diag_refundCard.setLocationRelativeTo(null);
diag_refundCard.setVisible(true);
}
}
});
//用户界面
mainJFrame_3.setVisible(true);
}
}
管理员界面
//文件名:AdministratorInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AdministratorInterface {
//管理员界面组件
static JFrame mainJFrame_4=new JFrame();
static JLabel lbl=new JLabel("ATM柜员机模拟程序——管理员界面",JLabel.CENTER);
//本机近期资金出入明细界面组件
static JDialog diag_recentFund=new JDialog(mainJFrame_4);
static JScrollPane sp_recentFund=new JScrollPane();
static JButton bt_return_recentFund=new JButton("返回");
//本机所有账户的历史记录界面组件
static JDialog diag_historyOfAll=new JDialog(mainJFrame_4);
static JScrollPane sp_historyOfAll=new JScrollPane();
static JButton bt_return_historyOfAll=new JButton("返回");
//用户账号解锁界面组件
static JDialog diag_userAccountUnlock=new JDialog(mainJFrame_4);
//退出界面组件
static JDialog diag_signOut=new JDialog(mainJFrame_4);
static JButton bt_close=new JButton("关闭");
static JButton bt_cancel=new JButton("取消");
//管理员界面组件
static JButton bt_recentFund=new JButton("本机近期资金出入明细");
static JButton bt_historyOfAll=new JButton("本机所有账户的历史记录");
static JButton bt_userAccountUnlock=new JButton("用户账号解锁");
static JButton bt_signOut=new JButton("退出");
public static void main(String[] args) {
// TODO Auto-generated method stub
//管理员界面
mainJFrame_4.setTitle("ATM柜员机模拟程序——管理员界面");
mainJFrame_4.setBounds(0, 0, 800, 600);
mainJFrame_4.setLocationRelativeTo(null);
mainJFrame_4.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container container=mainJFrame_4.getContentPane();
container.setLayout(null);
container.add(lbl);
lbl.setBounds(0, 75, 800, 50);
lbl.setFont(new Font("楷体",Font.BOLD,40));
//本机近期资金出入明细界面
diag_recentFund.setTitle("本机近期资金出入明细");
diag_recentFund.setSize(800, 600);
diag_recentFund.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
diag_recentFund.add(sp_recentFund);
diag_recentFund.add(bt_return_recentFund);
bt_return_recentFund.setFont(new Font("黑体",Font.BOLD,15));
bt_return_recentFund.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_recentFund) {
diag_recentFund.dispose();
}
}
});
container.add(bt_recentFund);
bt_recentFund.setBounds(300, 200, 200, 50);
bt_recentFund.setFont(new Font("黑体",Font.BOLD,15));
bt_recentFund.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_recentFund) {
diag_recentFund.setLocationRelativeTo(null);
diag_recentFund.setVisible(true);
}
}
});
//本机所有账户的历史记录界面
diag_historyOfAll.setTitle("本机所有账户的历史记录");
diag_historyOfAll.setSize(800, 600);
diag_historyOfAll.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
diag_historyOfAll.add(sp_historyOfAll);
diag_historyOfAll.add(bt_return_historyOfAll);
bt_return_historyOfAll.setFont(new Font("黑体",Font.BOLD,15));
bt_return_historyOfAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_return_historyOfAll) {
diag_historyOfAll.dispose();
}
}
});
container.add(bt_historyOfAll);
bt_historyOfAll.setBounds(300, 300, 200, 50);
bt_historyOfAll.setFont(new Font("黑体",Font.BOLD,14));
bt_historyOfAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_historyOfAll) {
diag_historyOfAll.setLocationRelativeTo(null);
diag_historyOfAll.setVisible(true);
}
}
});
//用户账号解锁界面
diag_userAccountUnlock.setTitle("用户账号解锁");
diag_userAccountUnlock.setSize(400, 300);
diag_userAccountUnlock.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
container.add(bt_userAccountUnlock);
bt_userAccountUnlock.setBounds(300, 400, 200, 50);
bt_userAccountUnlock.setFont(new Font("黑体",Font.BOLD,20));
bt_userAccountUnlock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_userAccountUnlock) {
diag_userAccountUnlock.setLocationRelativeTo(null);
diag_userAccountUnlock.setVisible(true);
}
}
});
//退出界面
diag_signOut.setTitle("退出");
diag_signOut.setSize(400, 300);
diag_signOut.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
diag_signOut.add(bt_close);
bt_close.setFont(new Font("黑体",Font.BOLD,15));
bt_close.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_close) {
diag_signOut.dispose();
mainJFrame_4.dispose();
new SystemSettingInterface().main(args);
}
}
});
diag_signOut.add(bt_cancel);
bt_cancel.setFont(new Font("黑体",Font.BOLD,15));
bt_cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_cancel) {
diag_signOut.dispose();
}
}
});
container.add(bt_signOut);
bt_signOut.setBounds(300, 500, 200, 50);
bt_signOut.setFont(new Font("黑体",Font.BOLD,20));
bt_signOut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton bt=(JButton)e.getSource();
if(bt==bt_signOut) {
diag_signOut.setLocationRelativeTo(null);
diag_signOut.setVisible(true);
}
}
});
//管理员界面
mainJFrame_4.setVisible(true);
}
}