⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 distill.java

📁 这个系统的功能是模拟ATM机的登陆、查询余额、取款、更改密码等功能
💻 JAVA
字号:

/*****************************************
 * <p>Title: ATM自动取款机</p>
 *
 * <p>Description: 模拟</p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author vinky_sc
 * @version 1.0
 *****************************************/


import javax.swing.JFrame;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import javax.swing.UIManager;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.awt.Toolkit;
import java.awt.Dimension;

/******************************************
 * 取款窗口(功能窗口)
 *
 * 执行取款操作
 *****************************************/

public class distill extends JFrame {
    
    Client user = new Client();
    atmScreen main = new atmScreen();
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();

    public distill() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(xYLayout1);
        jLabel1.setBackground(UIManager.getColor("ComboBox.selectionBackground"));
        jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 16));
        this.getContentPane().setBackground(Color.lightGray);
        this.setResizable(false);
        setSize(new Dimension(400, 330));
        setTitle("模拟ATM自动取款机--取款");
        jLabel1.setToolTipText("");
        jLabel1.setText("欢迎使用ATM自动取款机");
        jButton2.addActionListener(new distill_jButton2_actionAdapter(this));
        jButton1.addActionListener(new distill_jButton1_actionAdapter(this));
        jTextField1.setBackground(Color.cyan);
        this.getContentPane().add(jLabel1, new XYConstraints(108, 19, 185, 35));
        jButton2.setText("返  回");
        jButton1.setText("确  定");
        xYLayout1.setWidth(400);
        xYLayout1.setHeight(300);
        jTextField1.setText("0");
        jLabel6.setText(" 每天限取5000元,若带来不便,请谅解!");
        jLabel5.setText(" 请输入你取款的金额:");
        jLabel4.setText(" 但每次取款的金额不能超过2000元!");
        jLabel3.setText(" 例如:100、200、500、1000等。");
        jLabel2.setText(" 说明:每次取款只能取100的倍数!");
        this.getContentPane().setBackground(Color.lightGray);
        this.getContentPane().add(jLabel2, new XYConstraints(75, 61, 217, 30));
        this.getContentPane().add(jButton1, new XYConstraints(75, 221, 95, 30));
        this.getContentPane().add(jButton2, new XYConstraints(202, 221, 95, 30));
        this.getContentPane().add(jLabel3, new XYConstraints(75, 90, 217, 30));
        this.getContentPane().add(jLabel4, new XYConstraints(75, 118, 217, 30));
        this.getContentPane().add(jLabel5, new XYConstraints(56, 179, 140, 30));
        this.getContentPane().add(jTextField1,
                                  new XYConstraints(205, 179, 100, 29));
        this.getContentPane().add(jLabel6, new XYConstraints(75, 147, 230, 30));
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        this.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        this.setVisible(true);
    }

//返回按钮,功能返回菜单窗口
    public void jButton2_actionPerformed(ActionEvent e) {
        new menu();
        this.dispose();
    }
//取款执行按钮,需判断是否操作成功。
    public void jButton1_actionPerformed(ActionEvent e) {
        String id = main.aa;                                    //获取当前客户的卡号
        Float money = new Float(jTextField1.getText());         //从输入框中获取,客户取款的金额,并转换成Float类型
        float mon = money.floatValue();                         //将Float的对象的值传递给mon
        int m = (int)mon/100*100;                               //对客户输入的金额判断是否为100的倍数,不是就强制装换成
        int n = user.reducemoney(id,mon);                       //调用取款操作,并返回一个整数
        //对应操作弹出的提示,sum为每次取款的总金额。(似乎没能实现)
        switch(n)
        {
        case 1:JOptionPane.showMessageDialog(this,"恭喜你!操作成功!你可以看看你的余额!你本次交易的金额为"+mon,"提 示",JOptionPane.WARNING_MESSAGE);new menu();this.dispose();break;
        case 0:JOptionPane.showMessageDialog(this,"恭喜你!操作成功!你可以看看你的余额!你本次交易的金额为"+m,"提 示",JOptionPane.WARNING_MESSAGE);new menu();this.dispose();break;
        case -1:JOptionPane.showMessageDialog(this,"对不起!操作失败!请重新操作!","提 示",JOptionPane.WARNING_MESSAGE);jTextField1.setText("0");break;
        case -2:JOptionPane.showMessageDialog(this,"对不起!操作失败!交易金额不能为负或小于100!请仔细阅读说明!","提 示",JOptionPane.WARNING_MESSAGE);jTextField1.setText("0");break;
        case -3:JOptionPane.showMessageDialog(this,"对不起!操作失败!余额不足或是交易金额大于2000!","提 示",JOptionPane.WARNING_MESSAGE);jTextField1.setText("0");break;
        case -4:JOptionPane.showMessageDialog(this,"对不起!操作失败!你本次登陆取款金额不能大于5000!","提 示",JOptionPane.WARNING_MESSAGE);jTextField1.setText("0");break;
        }
    }
}

class distill_jButton2_actionAdapter implements ActionListener {
    private distill adaptee;
    distill_jButton2_actionAdapter(distill adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class distill_jButton1_actionAdapter implements ActionListener {
    private distill adaptee;
    distill_jButton1_actionAdapter(distill adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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