📄 atmscreen.java
字号:
/******************************************
* <p>Title: ATM自动取款机</p>
*
* <p>Description: 模拟</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author vinky_sc
* @version 1.0
*****************************************/
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.UIManager;
import javax.swing.JLabel;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*****************************************
* 客户登陆窗口
*
* 主要是输入卡号和密码
*****************************************/
public class atmScreen extends JFrame {
Client user = new Client(); //创建一个客户的对象
private static float sum = 5000;
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
public static String aa = ""; //aa是一个关键变量,用来传递客户的卡号
JLabel jLabel1 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JPasswordField jPasswordField1 = new JPasswordField();
JLabel jLabel10 = new JLabel();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
public atmScreen() //构造函数
{
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit(); //初始化窗口里的东西
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
this.setResizable(false);
setSize(new Dimension(400, 330)); //设置窗口大小
setTitle("模拟ATM自动取款机"); //设置窗口标题
contentPane.setBackground(Color.lightGray);
contentPane.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
contentPane.setMaximumSize(new Dimension(400, 330));
contentPane.setMinimumSize(new Dimension(400, 330));
contentPane.setToolTipText("");
contentPane.setInputVerifier(null);
jLabel1.setBackground(UIManager.getColor("ComboBox.selectionBackground"));
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 16));
jLabel1.setToolTipText("");
jLabel1.setText("欢迎使用ATM自动取款机");
jLabel3.setText(" 操作顺序如下:");
jLabel4.setText("1、输入你的卡号");
jLabel5.setText("2、输入你的密码");
jLabel6.setText("3、选择你需要的操作");
jLabel7.setText("若给你带来不便,请你见谅!");
jLabel8.setText("卡号:");
jLabel9.setText("密码:");
jTextField1.setBackground(Color.cyan);
jTextField1.setText("请输入你的卡号");
jButton1.setText("确认");
jButton1.addActionListener(new atmScreen_jButton1_actionAdapter(this));
jButton2.setText("退出");
jButton2.addActionListener(new atmScreen_jButton2_actionAdapter(this));
jPasswordField1.setBackground(Color.cyan);
jPasswordField1.setText("");
jLabel10.setText("联系方式:028-8596693");
jLabel11.setText("若有出现异常,请联系工作人员");
jLabel12.setText("版权所有 违者不究");
contentPane.add(jLabel9, new XYConstraints(197, 119, 52, 21));
contentPane.add(jButton1, new XYConstraints(205, 189, 71, 28));
contentPane.add(jButton2, new XYConstraints(305, 189, 68, 27));
contentPane.add(jTextField1, new XYConstraints(261, 81, 97, 25));
contentPane.add(jLabel8, new XYConstraints(197, 81, 53, 24));
contentPane.add(jPasswordField1, new XYConstraints(261, 116, 97, -1));
contentPane.add(jLabel6, new XYConstraints(56, 166, -1, 25));
contentPane.add(jLabel10, new XYConstraints(32, 228, 156, 23));
contentPane.add(jLabel7, new XYConstraints(31, 254, -1, 29));
contentPane.add(jLabel11, new XYConstraints(17, 193, 171, 32));
contentPane.add(jLabel12, new XYConstraints(228, 237, 124, 51));
contentPane.add(jLabel3, new XYConstraints(25, 73, 145, 29));
contentPane.add(jLabel4, new XYConstraints(56, 106, 114, 25));
contentPane.add(jLabel5, new XYConstraints(56, 135, 114, 25));
contentPane.add(jLabel1, new XYConstraints(108, 20, 185, 35));
}
public static void setsum(float a)
{
sum -= a;
}
public static float getsum()
{
return sum;
}
//以下为各按钮处理事件
public void jButton1_actionPerformed(ActionEvent e) {
String pwd = new String(jPasswordField1.getPassword()); //获取客户输入的密码
String id = jTextField1.getText(); //获取客户输入的卡号
//如果卡号和密码都正确,进入菜单窗口,否则弹出对应警告
if(user.checkAccount(id))
{
if(user.checkPwd(id,pwd))
{
aa = id; //将正确卡号传给aa,为后面的窗口提供参数
//setID(id);
new menu().setVisible(true);
this.dispose(); //关闭当前窗口
}
else//弹出警告
{
JOptionPane.showMessageDialog(this,"你的密码输入错误!请重新输入!","警 告",JOptionPane.WARNING_MESSAGE);
jPasswordField1.setText("");
jTextField1.setText("请输入你的卡号");
}
}
else//弹出警告
{
JOptionPane.showMessageDialog(this,"你的卡号输入错误!请重新输入!","警 告",JOptionPane.WARNING_MESSAGE);
jTextField1.setText("请输入你的卡号");
jPasswordField1.setText("");
}
}
//退出按钮的事件,退出系统
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
//下面是按钮事件处理所需代码,由JBuilder自动生成
class atmScreen_jButton2_actionAdapter implements ActionListener {
private atmScreen adaptee;
atmScreen_jButton2_actionAdapter(atmScreen adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class atmScreen_jButton1_actionAdapter implements ActionListener {
private atmScreen adaptee;
atmScreen_jButton1_actionAdapter(atmScreen adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -