用GUI封装过后写的ATM就很简单,只是有很多东西在别的地方写的,所以看着非常简单。内容太多了,其他的我就不发了就发一个主界面吧。
package ATM0428;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
import javax.swing.JFrame;
/** * 主界面 * @author 45470 * */
public class MyJFrame extends JFrame{
private MyJButton m1=new MyJButton("查询", 100, 50, 80, this);
private MyJButton m2=new MyJButton("改密", 100, 150, 80, this);
private MyJButton m3=new MyJButton("存款", 300, 50, 80, this);
private MyJButton m4=new MyJButton("取款", 300, 150, 80, this);
private MyJButton m5=new MyJButton("取卡", 300, 250, 80, this);
public MyJFrame(){
this.setLayout(null);
m1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
MyJFrame.this.dispose();
MyBalance m=new MyBalance();
} });
m2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
MyJFrame.this.dispose(); Micronesia mc=new Micronesia();
} });
m3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
MyJFrame.this.dispose();
MyDeposit md=new MyDeposit();
} });
m4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
MyJFrame.this.dispose();
MyWithdraw mw=new MyWithdraw();
} });
m5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
MyJFrame.this.dispose(); OUT o=new OUT();
} });
this.setSize(500, 400);
this.setVisible(true);
this.setDefaultCloseOperation(3);
this.setLocationRelativeTo(null);
}
}