用java编ATM提款机
- 提问者网友:留有余香
- 2021-05-09 00:19
最好是用GUI的
其功能有如下:
1:登陆
2:新建用户
3:提款
4:取款
5:查询
6:欢迎界面
我的邮箱:final0fantasy0@hotmail.com
- 五星知识达人网友:鱼芗
- 2021-05-09 01:39
我用C++做过一个,java应该更加好做,需要的话密我
- 1楼网友:独钓一江月
- 2021-05-09 04:08
这个也就只能做一个GUI界面吧。功能根本没法实现。
- 2楼网友:神也偏爱
- 2021-05-09 02:40
免费的不会有人做
- 3楼网友:鱼忧
- 2021-05-09 02:19
以前正好写过一个 拿去参考吧
/////////////////////////////////////////////////////////
// Create By Fogers
// Date: 2005/11/6
////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class H
{
public static void main(String[] args)
{
buju bj=new buju();
bj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bj.show();
}
}
class buju extends JFrame implements ActionListener
{
Container A;
JPanel m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19;
JRadioButton r1,r2;
JComboBox c;
static JProgressBar j;
JTextField t,t1,t2,t3,t4,t5,t6,t7;
JPasswordField p;
JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13;
CardLayout f;
GridBagLayout h;
String name[]={"上海","北京","天津","成都","广州","深圳","重庆","武汉","郑州"};
buju()
{
setTitle("horcel ATM自动取款机 V1.0 ");
setBounds(250,250,450,450);
A=getContentPane();
m1=new JPanel();m2=new JPanel();m3=new JPanel();m4=new JPanel();m5=new JPanel();m6=new JPanel();m7=new JPanel();
m8=new JPanel();m9=new JPanel();m10=new JPanel();m11=new JPanel();m12=new JPanel();m13=new JPanel();m14=new JPanel();m15=new JPanel();
l1=new JLabel("用 户 名 :");l2=new JLabel("用户密码:");l3=new JLabel();l4=new JLabel();l5=new JLabel();
l6=new JLabel();l7=new JLabel("");l8=new JLabel("帐 号 :");l9=new JLabel("密 码 :");
l10=new JLabel("重复密码 :");l11=new JLabel("性 别 :");l12=new JLabel("省 份 :");
l13=new JLabel("身份证号 :");l14=new JLabel("保密邮箱 :");l15=new JLabel("地 址 :");l17=new JLabel();
l18=new JLabel("");l19=new JLabel("请输入取款金额:");
t=new JTextField(10); t1=new JTextField(10);t2=new JTextField(10);t3=new JTextField(10);
t4=new JTextField(10);t5=new JTextField(10);t6=new JTextField(10);t7=new JTextField(10);
p=new JPasswordField(10);
r1=new JRadioButton("男");r2=new JRadioButton("女");
c=new JComboBox(name);
j=new JProgressBar(JProgressBar.HORIZONTAL,0,100);
j.setValue(0);
j.setStringPainted(true);
j.setBorderPainted(true);
b1=new JButton("登陆");b2=new JButton("退出");b3=new JButton("取款");b4=new JButton("查帐");
b5=new JButton("转帐");b6=new JButton("修改密码");b7=new JButton("返回登陆框");
b8=new JButton("退出");b9=new JButton("注册");b10=new JButton("提交");b11=new JButton("取消");
b12=new JButton("确定");b13=new JButton("取消");
f=new CardLayout();
A.setLayout(f);
h=new GridBagLayout();
m10.setLayout(h);
GridBagConstraints g=new GridBagConstraints();
g.fill=GridBagConstraints.HORIZONTAL;
g.gridwidth=2;
g.gridheight=2;
g.weightx=1;
g.weighty=1;
g.gridx=3;
g.gridy=2;
m10.add(l8,g);
g.gridy=6;
m10.add(l9,g);
g.gridy=10;
m10.add(l10,g);
g.gridy=14;
m10.add(l11,g);
g.gridy=18;
m10.add(l12,g);
g.gridy=22;
m10.add(l13,g);
g.gridy=26;
m10.add(l14,g);
g.gridy=30;
m10.add(l15,g);
g.gridx=7;
g.gridy=2;
m10.add(t1,g);
g.gridy=6;
m10.add(t2,g);
g.gridy=10;
m10.add(t3,g);
g.gridy=14;
m10.add(r1,g);
g.gridy=18;
m10.add(c,g);
g.gridy=22;
m10.add(t4,g);
g.gridy=26;
m10.add(t5,g);
g.gridy=30;
m10.add(t6,g);
g.gridx=10;
g.gridy=14;
m10.add(r2,g);
g.gridx=4;
g.gridy=34;
m10.add(b10,g);
g.gridx=10;
g.gridy=34;
m10.add(b11,g);
g.gridx=1;
g.gridy=34;
m10.add(l17,g);
m1.setLayout(new BorderLayout());
m2.setLayout(new BorderLayout());
m6.setLayout(new GridLayout(6,3));
m7.setLayout(new GridLayout(6,3));
m11.setLayout(new GridLayout(5,1));
m4.setLayout(new BorderLayout());
m8.add(l2);m8.add(p);
m9.add(l7);
m4.add(m8,BorderLayout.NORTH);
m4.add(m9,BorderLayout.CENTER);
m3.add(l1);m3.add(t);
m5.add(b1);m5.add(b2);m5.add(b9);
m6.add(b3);m6.add(b4);m6.add(b5);m6.add(b6);
m7.add(l3);m7.add(l4);m7.add(l5);m7.add(l6);m7.add(b7);m7.add(b8);
m1.add(m3,BorderLayout.NORTH);
m1.add(m4,BorderLayout.CENTER);
m1.add(m5,BorderLayout.SOUTH);
m2.add(m6,BorderLayout.EAST);
m2.add(m7,BorderLayout.WEST);
m12.add(j);m13.add(l18);m14.add(l19);m14.add(t7);m15.add(b12);m15.add(b13);
m11.add(m12);m11.add(m13);m11.add(m14);m11.add(m15);
A.add(m1,"登陆框");
A.add(m2,"选项框");
A.add(m10,"注册框");
A.add(m11,"进度条");
f.show(A,"登陆框");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
b13.addActionListener(this);
}
public void run()
{
for(int number=0;number<=100;number++)
{
j.setValue(number);
j.setStringPainted(true);
j.setBorderPainted(true);
try{
Thread.sleep(200);
}
catch(Exception e){}
}
}
public void actionPerformed(ActionEvent e)
{
String t1,t2,t3;
char[] p1;
t1=t.getText();
t3=t7.getText();
p1=p.getPassword();
t2=new String(p1);
if(e.getSource()==b1)
{
if(t1.equals("")||t2.equals(""))
l7.setText("用户名或密码不能为空!");
else if(t1.equals("horcel")&&t2.equals("123"))
{
f.show(A,"选项框");
t.setText(null);
p.setText(null);
}
else
{
l7.setText("登陆失败!!!");
t.setText(null);
p.setText(null);
}
}
if(e.getSource()==b3)
f.show(A,"进度条");
if(e.getSource()==b7)
f.show(A,"登陆框");
if(e.getSource()==b2||e.getSource()==b8||e.getSource()==b11)
System.exit(0);
if(e.getSource()==b9)
f.show(A,"注册框");
if(e.getSource()==b12)
if(t3.equals(""))
l18.setText("请输入取款金额!!");
else
{
l18.setText("请稍候.......");
run();
}
if(e.getSource()==b13)
f.show(A,"选项框");
}
}