基于java的Swing+MySQL银行ATM管理系统(java+mysql+swing)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

431523082708

441523082708

451523082708

461523082708

471523082708

481523082708

基于java的Swing+MySQL银行ATM管理系统(java+mysql+swing)

启动类:LoginFrame

登录用户:
user1 123456
user2 123456
user3 123456

功能:查询余额、取款、存款、转账

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/**
* 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();
outputField.setBounds(199, 84, 117, 24);
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) {
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);
if(i>0){
setVisible(false);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

private JPanel contentPane;
private JTextField out_nameField;
private JTextField out_moneyField;
//private com.shao.model.user user;
private com.shao.model.user user_query_deposit;
private com.shao.model.user user_modMoney_deposit;
private com.shao.model.user user_query_withdraw;
private com.shao.model.user user_modMoney_withdraw;

/**
* Create the frame.
*/
public transferFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 527, 358);
setTitle(name);
setLocationRelativeTo(null);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel lblNewLabel = new JLabel("\u8F6C\u8D26\u7528\u6237\u540D\uFF1A");
lblNewLabel.setFont(new Font("新宋体", Font.BOLD, 20));
lblNewLabel.setBounds(105, 72, 126, 30);
contentPane.add(lblNewLabel);

out_nameField = new JTextField();
out_nameField.setBounds(245, 77, 150, 24);
contentPane.add(out_nameField);
out_nameField.setColumns(10);

JLabel lblNewLabel_1 = new JLabel("\u8F6C\u8D26\u91D1\u989D\uFF1A");
lblNewLabel_1.setFont(new Font("新宋体", Font.BOLD, 20));
lblNewLabel_1.setBounds(105, 141, 112, 30);
contentPane.add(lblNewLabel_1);

out_moneyField = new JTextField();
out_moneyField.setBounds(243, 146, 152, 24);
contentPane.add(out_moneyField);
out_moneyField.setColumns(10);

JButton OKButton = new JButton("\u786E\u8BA4");
OKButton.setFont(new Font("新宋体", Font.BOLD, 17));
OKButton.setBounds(104, 225, 113, 27);
contentPane.add(OKButton);
OKButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int res = JOptionPane.showConfirmDialog(null, "确认此次转账?", "转账确认", JOptionPane.YES_NO_OPTION);
if (res == JOptionPane.YES_OPTION) {
user_query_deposit = ExecuteSQL.query(out_nameField.getText());//转出钱
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32



public class transferFrame extends JFrame {

private JPanel contentPane;
private JTextField out_nameField;
private JTextField out_moneyField;
//private com.shao.model.user user;
private com.shao.model.user user_query_deposit;
private com.shao.model.user user_modMoney_deposit;
private com.shao.model.user user_query_withdraw;
private com.shao.model.user user_modMoney_withdraw;

/**
* Create the frame.
*/
public transferFrame(final String name) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 527, 358);
setTitle(name);
setLocationRelativeTo(null);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel lblNewLabel = new JLabel("\u8F6C\u8D26\u7528\u6237\u540D\uFF1A");
lblNewLabel.setFont(new Font("新宋体", Font.BOLD, 20));
lblNewLabel.setBounds(105, 72, 126, 30);
contentPane.add(lblNewLabel);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 * 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);
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);
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);
}

});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
				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 SignFrame extends JFrame {

private JPanel contentPane;
private JTextField u_name;
private JPasswordField u_password;
private JPasswordField u_password_1;
private user user;


//注册按钮监听器
class OKButtonAction implements ActionListener {

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
        // TODO Auto-generated catch block
e.printStackTrace();
}
ExecuteSQL.close();
return u;
}

//注册,添加用户信息
public static int addUser(String name, String password) {
int i = 0;
String sql = "insert into bank(name,password,balance)"
+ "values('" + name + "','" + password + "','" + 0 + "')";
i = ExecuteSQL.executeUpdate(sql);
ExecuteSQL.close();
return i;

}

//查询用户信息
public static user query(String name) {
user u = new user();
String sql = "select name,balance from bank where name = '" + name + "'";
ResultSet rs = ExecuteSQL.executeQuery(sql);
try {
while (rs.next()) {
u.setName(rs.getString("name"));
u.setbalance(rs.getDouble("balance"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ExecuteSQL.close();
return u;
}

// 修改账户的余额
public static int modifyMoney(String name, double balance) {
user u = new user();
String sql = "update bank set balance = '" + balance + "' where name ='" + name + "'";
int i = ExecuteSQL.executeUpdate(sql);
ExecuteSQL.close();
return i;


项目链接:
https://javayms.github.io?id=421523082708201cb
https://javayms.pages.dev?id=421523082708201cb