怎样用JAVA编写一个ATM简单的应用程序

来源:百度知道 编辑:UC知道 时间:2024/06/20 19:13:49
求个全代码实现基本的存款 取款 查询就可以就想下面图片格式就行了

import javax.swing.*;
import java.awt.event.*;

public class SimAtm extends JFrame implements java.awt.event.ActionListener{

private static final long serialVersionUID = 1L;
private JButton[] buts = new JButton[4];
private String [] tils = new String[] {"存款", "取款", "查询", "退出"};
private int money = 0;
private JLabel lab = new JLabel();

public SimAtm() {
this.setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(400, 250, 420, 200);
int w = 100;
int h = 30;
lab.setForeground(java.awt.Color.red);
lab.setBounds(0, 50, 400, 50);
for(int i = 0; i < 4; i ++) {
buts[i] = new JButton(tils[i]);
buts[i].addActionListener(this);
buts[i].setBounds(i * w, 0,w, h );
this.add(buts[i]);
}
this.add(lab);
this.setVisible(true);
}

public s