📄 atminput.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Locale;
import java.util.Date;
import java.sql.*;
import java.text.*;
import javax.swing.border.*;
public class AtmInput extends JPanel
{
ReadAtmID idsource= new ReadAtmID();
JLabel l1=new JLabel("卡号:");
JLabel l2=new JLabel("姓名:");
JLabel l3=new JLabel("密码:");
JLabel l4=new JLabel("身份证:");
JLabel l5=new JLabel("金额:");
JTextField txtCard= new JTextField(10);
JTextField txtName= new JTextField(10);
JPasswordField txtPwd= new JPasswordField(10);
JTextField txtID= new JTextField(10);
JTextField txtMoney= new JTextField(10);
JButton btConfirm=new JButton("开户");
JButton btCancel=new JButton("取消");
JButton btBack=new JButton("返回");
Icon img=new ImageIcon(".\\gif\\ts.gif");
JLabel tsGif=new JLabel(img);
Component f;
Date today =new Date();
ReadAtmID Idsource = new ReadAtmID();
AtmAccount Customer;
private ActionListener listener=new ActionResponse();
public AtmInput (Component ComponentF)
{
f=ComponentF;
this.setLayout(null);
this.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createLineBorder(Color.BLACK,1),
"请输入用户信息",TitledBorder.CENTER,TitledBorder.TOP));
tsGif.setBounds(180,50,80,80);
l1.setBounds(280,120,50,30);
l2.setBounds(280,150,50,30);
l3.setBounds(280,180,50,30);
l4.setBounds(280,210,50,30);
l5.setBounds(280,240,50,30);
txtCard.setBounds(350,120,150,20);
txtName.setBounds(350,150,150,20);
txtPwd.setBounds(350,180,150,20);
txtID.setBounds(350,210,150,20);
txtMoney.setBounds(350,240,150,20);
btConfirm.setBounds(280,270,70,30);
btCancel.setBounds(355,270,70,30);
btBack.setBounds(430,270,70,30);
btConfirm.addActionListener(listener);
btCancel.addActionListener(listener);
btBack.addActionListener(listener);
this.add(tsGif);
this.add(l1);
this.add(l2);
this.add(l3);
this.add(l4);
this.add(l5);
this.add(txtCard);
this.add(txtName);
this.add(txtPwd);
this.add(txtID);
this.add(txtMoney);
this.add(btConfirm);
this.add(btCancel);
this.add(btBack);
txtCard.setText(String.valueOf(idsource.getid()));
}
class ActionResponse implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
String cmd = e.getActionCommand();
if (cmd.equals("开户"))
{
Locale CurLocale=new Locale("zh","CN");
txtCard.setText(String.valueOf(idsource.getid()));
NumberFormat curformater=NumberFormat.getCurrencyInstance(CurLocale);
//Customer.Sum=curformater.format(Double.parseDouble(txtMoney.getText()));
Customer =new AtmAccount();
Customer.CardID=txtCard.getText();
Customer.Name=txtName.getText();
Customer.Password=txtPwd.getPassword();
//JOptionPane.showMessageDialog(f, "您的输入可能有错!", "提示", JOptionPane.INFORMATION_MESSAGE);
Customer.Sum=Double.parseDouble(txtMoney.getText());
Customer.CreateDate=today;
Customer.Licence=txtID.getText();
Customer.LostFlag=false;
Customer.OutDate=today;
String title = "请确定输入用户信息";
int type = JOptionPane.INFORMATION_MESSAGE;
SimpleDateFormat DateFormatter=new SimpleDateFormat("yyyy/MM/dd");
String[] options={"开户","取消"};
int optionType=JOptionPane.YES_NO_OPTION;
int messageType=JOptionPane.QUESTION_MESSAGE;
String message = "姓名:"+Customer.Name+"\n金额:"+curformater.format(Customer.Sum)+"\n身份证号: "+Customer.Licence+"\n办卡日期: "+DateFormatter.format(Customer.CreateDate);
System.out.println(DateFormatter.format(Customer.CreateDate));
int result = JOptionPane.showOptionDialog(f,message, title, optionType,messageType,null,options,options[1]);
if (result == JOptionPane.YES_OPTION)
{//UpdateNew(Customer.CardID,Customer.Name,Customer.Password,Customer.Sum,Customer.CreateDate,Customer.Licence,false,Customer.OutDate);
try{ Customer.UpdateNew(); }
catch(SQLException Exp)
{}
catch(ClassNotFoundException Exp)
{}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -