您的位置首页百科知识

JAVA程序设计-ATM的解释

JAVA程序设计-ATM的解释

的有关信息介绍如下:

JAVA程序设计-ATM的解释

//设置菜单

myMenu=new MenuBar(); 建立菜单条对象

fileMenu=new Menu("File");

helpMenu=new Menu("Help"); 建立2个菜单分别是file和help

myMenu.add(fileMenu);

myMenu.add(helpMenu);把2个菜单对象放到菜单条里面

fileMenuItem1=new MenuItem("Exit");

helpMenuItem1=new MenuItem("Version");建立2个菜单项

myMenu.add(fileMenu);

myMenu.add(helpMenu);这2行多余...是你的笔误吧

fileMenu.add(fileMenuItem1);

helpMenu.add(helpMenuItem1);把2个菜单项放到对应的菜单里面

fileMenuItem1.addActionListener(new ActionListener1());

helpMenuItem1.addActionListener(new ActionListener1()); 设置2个菜单项的事件处理函数用来响应用户的点击

win1.setMenuBar(myMenu);把这个菜单对象整个放到应用程序框架里面.

//设置对话框(help菜单)

dialog1=new MyDialog(win1,"关于简易ATM系统测试版",true);

dialog1.addWindowListener(this);建立一个对话框并添加事件处理函数来响应用户的动作

//用户名及密码

tx1=new TextField(10);

tx2=new TextField(10);2个text控件来接受名字和密码

//设置各个Button

win1.add(myP,BorderLayout.CENTER);

myP.setLayout(new FlowLayout());

myP.add(new Label("username:"));

myP.add(tx1);

myP.add(new Label("password:"));

myP.add(tx2);

btn1=new Button("登陆");

btn2=new Button("清除");

btn1.addActionListener(new ActionListener1());

btn2.addActionListener(new ActionListener1());

添加按钮和label来构造这个对话框对象

btn3=new Button("账户余额");

btn3.setForeground(Color.black);

btn3.setBackground(Color.WHITE);

btn3.addActionListener(new ActionListener1());

btn4=new Button("我要取款");

btn4.setForeground(Color.black);

btn4.setBackground(Color.WHITE);

btn4.addActionListener(new ActionListener1());

btn5=new Button("修改密码");

btn5.setForeground(Color.black);

btn5.setBackground(Color.WHITE);

btn5.addActionListener(new ActionListener1());

btn6=new Button("退出系统");

btn6.setForeground(Color.black);

btn6.setBackground(Color.WHITE);

btn6.addActionListener(new ActionListener1());

以上是构造每个按钮的细节.

myP.add(btn1);

myP.add(btn2);

win1.add(myP2,BorderLayout.EAST);

myP2.setLayout(new GridLayout(4,1));

myP2.add(btn3);

myP2.add(btn4);

myP2.add(btn5);

myP2.add(btn6);

把所有按钮和txt对象放到对话框中,构造完毕

logo=new Label("欢迎来到本系统!");

logo.setFont(new Font("Serif",Font.PLAIN,15));

win1.add(logo,BorderLayout.NORTH);

win1.setSize(600,400);

win1.setVisible(true);

win1.addWindowListener(this);在程序框架里面添加一行文字做程序开始的标题.

}

public static void main(String args[])

{

这里是主函数了

new JDBC();

//显示logo图片

Thread thread; 开一个线程对象用来显示GIF图片

Logo lg=new Logo("LOGO.GIF");

thread=new Thread(lg);

thread.start();

}