基于java+gui的银行管理系统(java+Gui)
功能介绍:
登录、打印、取款、改密、转账、查询、挂失、存款、退卡
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
if (user.getPassword().equals(u_password_field.getText())) {
try {
atmFrame frame = new atmFrame(user.getName());
frame.setTitle(user.getName());
frame.setVisible(true);
setVisible(false);
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
u_name_Field.setText("");
u_password_field.setText("");
}
} else {
JOptionPane.showMessageDialog(null, "找不到该用户,请先注册!");
u_name_Field.setText("");
u_password_field.setText("");
}
}
}
JOptionPane.showMessageDialog(null, "输入金额大于100000,请重新输入!");
outputField.setText("");
}
}
});
JButton backButton_1 = new JButton("\u8FD4\u56DE");
backButton_1.setFont(new Font("新宋体", Font.BOLD, 15));
backButton_1.setBounds(233, 159, 113, 27);
contentPane.add(backButton_1);
backButton_1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
atmFrame af = new atmFrame(name);
setVisible(false);
af.setVisible(true);
}
});
private JTextField u_name_Field;
private JPasswordField u_password_field;
private user user;
//登录事件监听器
class loginAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
user = ExecuteSQL.check(u_name_Field.getText(), u_password_field.getText());
if (user.getName() != null) {
if (user.getPassword().equals(u_password_field.getText())) {
try {
atmFrame frame = new atmFrame(user.getName());
frame.setTitle(user.getName());
frame.setVisible(true);
setVisible(false);
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
u_name_Field.setText("");
u_password_field.setText("");
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public LoginFrame() {
setTitle("\u7F51\u4E0A\u94F6\u884C");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 506, 385);
contentPane = new JPanel();
setLocationRelativeTo(null);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton LoginButton = new JButton("\u767B\u5F55");
LoginButton.setFont(new Font("新宋体", Font.BOLD, 20));
LoginButton.setBounds(92, 214, 120, 37);
JButton queryButton = new JButton("\u67E5\u8BE2");
queryButton.setBounds(99, 101, 113, 27);
contentPane.add(queryButton);
queryButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
user = ExecuteSQL.query(name);
DecimalFormat df = new DecimalFormat( "0.00 ");
JOptionPane.showMessageDialog(null,
"您的账户名:"+user.getName()+"\n"+"当前余额:¥"+user.getbalance()+"\n","信息提示",
JOptionPane.INFORMATION_MESSAGE);
}
});
JButton depositButton = new JButton("\u5B58\u6B3E");
depositButton.setBounds(99, 223, 113, 27);
contentPane.add(depositButton);
depositButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
depositFrame df = new depositFrame(name);
setVisible(false);
df.setVisible(true);
}
}
});
JButton transferButton = new JButton("\u8F6C\u8D26");
transferButton.setBounds(288, 223, 113, 27);
contentPane.add(transferButton);
transferButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
transferFrame wf = new transferFrame(name);
setVisible(false);
wf.setVisible(true);
}
});
}
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setBounds(402, 307, 72, 31);
contentPane.add(lblNewLabel);
}
}
收回框设置:
public class withdrawFrame extends JFrame {
private JPanel contentPane;
private JTextField outputField;
private com.shao.model.user user_query;
private com.shao.model.user user_modMoney;
/**
* Create the frame.
*/
public withdrawFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
setTitle(name);
setLocationRelativeTo(null);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
private JPanel contentPane;
private JTextField u_name_Field;
private JPasswordField u_password_field;
private user user;
//登录事件监听器
class loginAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
user = ExecuteSQL.check(u_name_Field.getText(), u_password_field.getText());
if (user.getName() != null) {
if (user.getPassword().equals(u_password_field.getText())) {
try {
atmFrame frame = new atmFrame(user.getName());
frame.setTitle(user.getName());
frame.setVisible(true);
setVisible(false);
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
u_name_Field.setText("");
} else {
JOptionPane.showMessageDialog(null, "余额不足,请重新输入!" + "\n" + "当前余额为:" + user_query.getbalance());
outputField.setText("");
}
}else {
JOptionPane.showMessageDialog(null, "系统不支持非100元整钞,请重新输入!");
outputField.setText("");
}
} else {
JOptionPane.showMessageDialog(null, "输入金额大于100000,请重新输入!");
outputField.setText("");
}
DecimalFormat df = new DecimalFormat( "0.00 ");
JOptionPane.showMessageDialog(null,
"您的账户名:"+user.getName()+"\n"+"当前余额:¥"+user.getbalance()+"\n","信息提示",
JOptionPane.INFORMATION_MESSAGE);
}
});
JButton depositButton = new JButton("\u5B58\u6B3E");
depositButton.setBounds(99, 223, 113, 27);
contentPane.add(depositButton);
depositButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
depositFrame df = new depositFrame(name);
setVisible(false);
df.setVisible(true);
}
});
JButton withdrawButton = new JButton("\u53D6\u6B3E");
withdrawButton.setBounds(288, 101, 113, 27);
JButton withdrawButton = new JButton("\u53D6\u6B3E");
withdrawButton.setBounds(288, 101, 113, 27);
contentPane.add(withdrawButton);
withdrawButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
withdrawFrame wf = new withdrawFrame(name);
setVisible(false);
wf.setVisible(true);
}
});
JButton transferButton = new JButton("\u8F6C\u8D26");
transferButton.setBounds(288, 223, 113, 27);
contentPane.add(transferButton);
contentPane.add(outputField);
outputField.setColumns(10);
JButton OKButton = new JButton("\u786E\u5B9A");
OKButton.setFont(new Font("新宋体", Font.BOLD, 15));
OKButton.setBounds(84, 159, 113, 27);
contentPane.add(OKButton);
OKButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("withdrawFrame.withdrawFrame(...).new ActionListener() {...}.actionPerformed()"+outputField.getText());
if (Float.parseFloat(outputField.getText()) < 100000) {
if(Float.parseFloat(outputField.getText())%100==0) {
* Create the frame.
*/
public atmFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 518, 434);
contentPane = new JPanel();
setTitle(name);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setLocationRelativeTo(null);
setContentPane(contentPane);
contentPane.setLayout(null);
} else {
JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
u_name_Field.setText("");
u_password_field.setText("");
}
} else {
JOptionPane.showMessageDialog(null, "找不到该用户,请先注册!");
u_name_Field.setText("");
u_password_field.setText("");
}
}
}
//注册事件监听器
class signAction implements ActionListener{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
SignFrame frame = new SignFrame();
frame.setVisible(true);
setVisible(false);
JOptionPane.showMessageDialog(null, "输入金额大于100000,请重新输入!");
outputField.setText("");
}
}
});
JButton backButton_1 = new JButton("\u8FD4\u56DE");
backButton_1.setFont(new Font("新宋体", Font.BOLD, 15));
backButton_1.setBounds(233, 159, 113, 27);
contentPane.add(backButton_1);
backButton_1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
atmFrame af = new atmFrame(name);
setVisible(false);
af.setVisible(true);
}
});
JLabel remindLabel = new JLabel("*\u5355\u7B14\u6700\u5927\u53EF\u53D610000");
/**
* Create the frame.
*/
public withdrawFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
setTitle(name);
setLocationRelativeTo(null);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabe = new JLabel("\u53D6\u6B3E\u91D1\u989D\uFF1A");
lblNewLabe.setFont(new Font("新宋体", Font.BOLD, 20));
lblNewLabe.setBounds(84, 75, 117, 38);
contentPane.add(lblNewLabe);
outputField = new JTextField();
}
}
});
}
/**
* Create the frame.
*/
public atmFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 518, 434);
contentPane = new JPanel();
setTitle(name);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setLocationRelativeTo(null);
setContentPane(contentPane);
contentPane.setLayout(null);
JButton queryButton = new JButton("\u67E5\u8BE2");
queryButton.setBounds(99, 101, 113, 27);
contentPane.add(queryButton);
queryButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
user = ExecuteSQL.query(name);
JLabel lblNewLabel = new JLabel("\u7528\u6237\u6307\u5357");
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setBounds(402, 307, 72, 31);
contentPane.add(lblNewLabel);
}
}
收回框设置:
public class withdrawFrame extends JFrame {
private JPanel contentPane;
private JTextField outputField;
private com.shao.model.user user_query;
private com.shao.model.user user_modMoney;
* Create the frame.
*/
public LoginFrame() {
setTitle("\u7F51\u4E0A\u94F6\u884C");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 506, 385);
contentPane = new JPanel();
setLocationRelativeTo(null);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton LoginButton = new JButton("\u767B\u5F55");
LoginButton.setFont(new Font("新宋体", Font.BOLD, 20));
LoginButton.setBounds(92, 214, 120, 37);
contentPane.add(LoginButton);
public void actionPerformed(ActionEvent e) {
atmFrame af = new atmFrame(name);
setVisible(false);
af.setVisible(true);
}
});
JLabel remindLabel = new JLabel("*\u5355\u7B14\u6700\u5927\u53EF\u53D610000");
remindLabel.setForeground(Color.RED);
remindLabel.setBounds(199, 126, 138, 18);
contentPane.add(remindLabel);
}
服务模块:
public class atmFrame extends JFrame {
private JPanel contentPane;
private user user;
// private LoginFrame lf;
/**
* Launch the application.
*/
contentPane.add(OKButton);
OKButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("withdrawFrame.withdrawFrame(...).new ActionListener() {...}.actionPerformed()"+outputField.getText());
if (Float.parseFloat(outputField.getText()) < 100000) {
if(Float.parseFloat(outputField.getText())%100==0) {
user_query = ExecuteSQL.query(name);
if (user_query.getbalance() > Double.parseDouble(outputField.getText())) {
double temp = user_query.getbalance() - Double.parseDouble(outputField.getText());
DecimalFormat df = new DecimalFormat( "0.00 ");
int i = ExecuteSQL.modifyMoney(name, temp);
}
}
//注册事件监听器
class signAction implements ActionListener{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
SignFrame frame = new SignFrame();
frame.setVisible(true);
setVisible(false);
}
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
atmFrame frame = new atmFrame(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public atmFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 518, 434);
contentPane = new JPanel();
setTitle(name);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setLocationRelativeTo(null);
JLabel remindLabel = new JLabel("*\u5355\u7B14\u6700\u5927\u53EF\u53D610000");
remindLabel.setForeground(Color.RED);
remindLabel.setBounds(199, 126, 138, 18);
contentPane.add(remindLabel);
}
服务模块:
public class atmFrame extends JFrame {
private JPanel contentPane;
private user user;
// private LoginFrame lf;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
atmFrame frame = new atmFrame(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}