atm_window.java

来自「JAVA 方法写的 ATM自助银行系统 代码清晰明了」· Java 代码 · 共 410 行

JAVA
410
字号
package ATM_Frame;

import java.awt.Color;
import java.awt.Container;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;

import ATM_Events.Chaxun_Print_M200;
import ATM_Events.Exit_TakeOutOther;
import ATM_Events.MakeSure_Return;
import ATM_Events.NumberEvent;
import ATM_Events.TakeoutMoney_M100;
import ATM_Events.XGmima_M300;
import ATM_Events.M500_M2000Event;
import ATM_ToolClass.TimeThread;
import ATM_ToolClass.Genggai;

public class ATM_window extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JPanel displayPane,topPane,flowPane,numPane;
	JButton topleftb1,topleftb2,topleftb3,topleftb4,
	        toprightb1,toprightb2,toprightb3,toprightb4,
	        flowcancel,flowcorrect,flowensure,flowexit;
	JLabel password,ensure,xgmima,reture,exitcard,takeout,chaxun;
	JTextField moneytf;
	JPasswordField passwordtf;
	String mima="123456";
	
	Container context;
	
	int i=9,k=2, temp=0;
	boolean Tn=false;
    static int Tl1=0,Tl2=0,Tl3=0,Tl4=0;
	static int Tr1=0,Tr2=0,Tr3=0,Tr4=1;
	static int AllMoney=10000;
	static int TakeoutMoney=0;
	static int RestTime=30;
	
	public ATM_window(){
		this.setTitle("中国建设银行ATM取款机");
		this.setBounds(300, 120, 400, 500);
		this.setLayout(null);
		context=this.getContentPane();
//上部面板的制作	
		topPane=new JPanel();
		topPane.setBounds(0, 0, 400, 250);
	    topPane.setBorder(new LineBorder(Color.black));
	    topPane.setLayout(null);
	    ImageIcon leftpicture=new ImageIcon("image/left.gif");
	    ImageIcon rightpicture=new ImageIcon("image/right.gif");
	    topleftb1=new JButton(leftpicture);
	    topleftb1.setBounds(15, 30, 45,30);
	    topleftb1.addActionListener(new M500_M2000Event(this,500));
	    topleftb2=new JButton(leftpicture);
	    topleftb2.setBounds(15, 80, 45, 30);
	    topleftb2.addActionListener(new M500_M2000Event(this,1000));
	    topleftb3=new JButton(leftpicture);
	    topleftb3.setBounds(15, 130, 45, 30);
	    topleftb3.addActionListener(new M500_M2000Event(this,2000));
	    topleftb4=new JButton(leftpicture);
	    topleftb4.addActionListener(new Exit_TakeOutOther(this));
	    topleftb4.setBounds(15, 180, 45, 30);
	    toprightb1=new JButton(rightpicture);
	    toprightb1.addActionListener(new TakeoutMoney_M100(this));
	    toprightb1.setBounds(330, 30, 45, 30);
	    toprightb2=new JButton(rightpicture);
	    toprightb2.addActionListener(new Chaxun_Print_M200(this));
	    toprightb2.setBounds(330, 80, 45, 30);
	    toprightb3=new JButton(rightpicture);
	    toprightb3.addActionListener(new XGmima_M300(this));
	    toprightb3.setBounds(330, 130, 45, 30);
	    toprightb4=new JButton(rightpicture);
	    toprightb4.setBounds(330, 180, 45, 30);
	    toprightb4.addActionListener(new MakeSure_Return(this));
	    displayPane=new JPanel();
	    displayPane.setBounds(70, 30, 250, 180);
	    displayPane.setBackground(Color.BLUE);
	    displayPane.setLayout(null);
	    //************************************
	    password=new JLabel("请输入密码: ");
	    password.setBounds(20, 85, 100, 25);
	    displayPane.add(password);//
	    passwordtf=new JPasswordField();
	    passwordtf.setBounds(50, 110, 140, 25);
	    passwordtf.setEditable(false);
	    displayPane.add(passwordtf);//
	    moneytf=new JTextField();
	    moneytf.setBounds(50, 110, 140, 25);
	    moneytf.setHorizontalAlignment(JTextField.CENTER);
	    moneytf.setEditable(false);
	    ensure=new JLabel("确定");
	    ensure.setBounds(220, 150, 50, 30);
	    displayPane.add(ensure);//
	    xgmima=new JLabel("修改密码");
	    xgmima.setBounds(195, 100, 60, 30);
	    reture=new JLabel("返回");
	    reture.setBounds(220, 150, 50, 30);
	    exitcard=new JLabel("退卡");
	    exitcard.setBounds(10, 150, 50, 30);
	    takeout=new JLabel("取款");
	    takeout.setBounds(220, 0, 50, 30);
	    chaxun=new JLabel("查询余额");
	    chaxun.setBounds(195, 50, 60, 30);
  
	    topPane.add(topleftb1);
	    topPane.add(topleftb2);
	    topPane.add(topleftb3);
	    topPane.add(topleftb4);
	    topPane.add(toprightb1);
	    topPane.add(toprightb2);
	    topPane.add(toprightb3);
	    topPane.add(toprightb4);
	    topPane.add(displayPane);
//下部面板的制作
	    flowPane=new JPanel();
		flowPane.setBounds(0, 250, 400, 250);
		flowPane.setBorder(new LineBorder(Color.blue));
		flowPane.setLayout(null);
		numPane=new JPanel();
		numPane.setBounds(20, 20, 240, 190);
		numPane.setBorder(new LineBorder(Color.darkGray));
        numPane.setLayout(null);
		
		while(i>=1){
			if(k>=0){
				temp=i-k;
				numadd(temp,new JButton(temp+""));
				k--;
			}
			else{
				k=2;
				i=temp-3;
			}
			
		}
		JButton num0=new JButton("0");
		num0.setBounds(40, 140, 60, 38);
		num0.addActionListener(new NumberEvent("0",this));
		numPane.add(num0);
		JButton num00=new JButton("00");
		num00.setBounds(120, 140,95, 38);
		num00.addActionListener(new NumberEvent("00",this));
		numPane.add(num00);
		
		flowcancel=new JButton(" 取消");
		flowcancel.setBounds(285, 25, 88, 40);
		flowcancel.setEnabled(false);
		flowcorrect=new JButton("更改");
		flowcorrect.setBounds(285, 70, 88, 40);
		flowcorrect.addActionListener(new Genggai(this));
		flowensure=new JButton("确定");
		flowensure.setBounds(285, 115, 88, 40);
		flowensure.setEnabled(false);
		flowexit=new JButton("退出");
		flowexit.setBounds(285, 160, 88, 40);
		flowexit.setEnabled(false);
		
		flowPane.add(numPane);
		flowPane.add(flowcancel);
		flowPane.add(flowcorrect);
		flowPane.add(flowensure);
		flowPane.add(flowexit);
		context.add(topPane);
		context.add(flowPane);
		
		
		
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	
	public void numadd(int i,JButton b){
		int XY[]={15,95,90,95,165,95,15,55,90,55,165,55,15,15,90,15,165,15};
		b.setBounds(XY[i*2-2], XY[i*2-1], 65, 38);
		String I=i+"";
	    b.addActionListener(new NumberEvent(I,this));
		numPane.add(b);
	}

	public JPasswordField getPasswordtf() {
		return passwordtf;
	}

	public void setPasswordtf(JPasswordField passwordtf) {
		this.passwordtf = passwordtf;
	}

	public JLabel getEnsure() {
		return ensure;
	}

	public void setEnsure(JLabel ensure) {
		this.ensure = ensure;
	}

	public JLabel getPassword() {
		return password;
	}

	public void setPassword(JLabel password) {
		this.password = password;
	}

	public JPanel getDisplayPane() {
		return displayPane;
	}

	public void setDisplayPane(JPanel displayPane) {
		this.displayPane = displayPane;
	}

	public JPanel getNumPane() {
		return numPane;
	}

	public void setNumPane(JPanel numPane) {
		this.numPane = numPane;
	}

	public JButton getToprightb4() {
		return toprightb4;
	}

	public void setToprightb4(JButton toprightb4) {
		this.toprightb4 = toprightb4;
	}

	public JLabel getChaxun() {
		return chaxun;
	}

	public void setChaxun(JLabel chaxun) {
		this.chaxun = chaxun;
	}

	public JLabel getExitcard() {
		return exitcard;
	}

	public void setExitcard(JLabel exitcard) {
		this.exitcard = exitcard;
	}



	public JLabel getReture() {
		return reture;
	}

	public void setReture(JLabel reture) {
		this.reture = reture;
	}

	public JLabel getTakeout() {
		return takeout;
	}

	public void setTakeout(JLabel takeout) {
		this.takeout = takeout;
	}

	public JLabel getXgmima() {
		return xgmima;
	}

	public void setXgmima(JLabel xgmima) {
		this.xgmima = xgmima;
	}



	public void setTr4(int tr4) {
		Tr4 = tr4;
	}

	public String getMima() {
		return mima;
	}

	public void setMima(String mima) {
		this.mima = mima;
	}

	public JTextField getMoneytf() {
		return moneytf;
	}

	public void setMoneytf(JTextField moneytf) {
		this.moneytf = moneytf;
	}

	public boolean isTn() {
		return Tn;
	}

	public void setTn(boolean tn) {
		Tn = tn;
	}

	public static int getAllMoney() {
		return AllMoney;
	}

	public static void setAllMoney(int allMoney) {
		AllMoney = allMoney;
	}

	public int getTr2() {
		return Tr2;
	}

	public void setTr2(int tr2) {
		Tr2 = tr2;
	}

	public int getTl1() {
		return Tl1;
	}

	public void setTl1(int tl1) {
		Tl1 = tl1;
	}

	public int getTl2() {
		return Tl2;
	}

	public void setTl2(int tl2) {
		Tl2 = tl2;
	}

	public int getTl3() {
		return Tl3;
	}

	public void setTl3(int tl3) {
		Tl3 = tl3;
	}

	public int getTl4() {
		return Tl4;
	}

	public void setTl4(int tl4) {
		Tl4 = tl4;
	}

	public int getTr1() {
		return Tr1;
	}

	public void setTr1(int tr1) {
		Tr1 = tr1;
	}

	public int getTr3() {
		return Tr3;
	}

	public void setTr3(int tr3) {
		Tr3 = tr3;
	}

	public int getTr4() {
		return Tr4;
	}

	public static int getTakeoutMoney() {
		return TakeoutMoney;
	}

	public static void setTakeoutMoney(int takeoutMoney) {
		TakeoutMoney = takeoutMoney+TakeoutMoney;
	}
	public static void setTakeoutMoney(int takeoutMoney,String str) {
		TakeoutMoney = 0;
	}

	public static int getRestTime() {
		return RestTime;
	}

	public static void setRestTime() {
		RestTime -= 1 ;
	}
	public static void setRestTime(int setresttime) {
		RestTime = setresttime ;
	}

	public JPanel getTopPane() {
		return topPane;
	}

	public void setTopPane(JPanel topPane) {
		this.topPane = topPane;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?