java图像界面ATM模拟程序Word文档格式.docx

上传人:b****5 文档编号:21439617 上传时间:2023-01-30 格式:DOCX 页数:23 大小:20.68KB
下载 相关 举报
java图像界面ATM模拟程序Word文档格式.docx_第1页
第1页 / 共23页
java图像界面ATM模拟程序Word文档格式.docx_第2页
第2页 / 共23页
java图像界面ATM模拟程序Word文档格式.docx_第3页
第3页 / 共23页
java图像界面ATM模拟程序Word文档格式.docx_第4页
第4页 / 共23页
java图像界面ATM模拟程序Word文档格式.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

java图像界面ATM模拟程序Word文档格式.docx

《java图像界面ATM模拟程序Word文档格式.docx》由会员分享,可在线阅读,更多相关《java图像界面ATM模拟程序Word文档格式.docx(23页珍藏版)》请在冰豆网上搜索。

java图像界面ATM模拟程序Word文档格式.docx

privatevoidinitComponents(){

cunkuan=newJButton();

qukuan=newJButton();

checked=newJButton();

reset=newJButton();

quit=newJButton();

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

setTitle("

ATM柜员模拟程序"

);

setName("

mianframe"

setResizable(false);

cunkuan.setText("

存款"

cunkuan.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEventevt){

cunkuanActionPerformed(evt);

}

});

qukuan.setText("

取款"

qukuan.addActionListener(newActionListener(){

qukuanActionPerformed(evt);

checked.setText("

查询"

checked.addActionListener(newActionListener(){

checkedActionPerformed(evt);

reset.setText("

修改密码"

reset.addActionListener(newActionListener(){

resetActionPerformed(evt);

quit.setText("

退出"

quit.addActionListener(newActionListener(){

quitActionPerformed(evt);

GroupLayoutlayout=newGroupLayout(getContentPane());

//GroupLayout它将组件按层次分组,以决定它们在Container中的位置

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(cunkuan)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,105,Short.MAX_VALUE)

.addComponent(reset))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup()

.addComponent(qukuan)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,143,Short.MAX_VALUE)

.addComponent(quit))

.addComponent(checked))

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(46,46,46)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addGap(51,51,51)

.addComponent(quit)

.addComponent(qukuan))

.addGap(57,57,57)

.addComponent(checked)

.addGap(39,39,39))

pack();

privatevoidquitActionPerformed(ActionEventevt){

LoginFrameload=newLoginFrame();

load.setVisible(true);

this.setVisible(false);

privatevoidresetActionPerformed(ActionEventevt){

Setpwsetpw=newSetpw(null);

setpw.setVisible(true);

this.setVisible(false);

privatevoidcheckedActionPerformed(ActionEventevt){

Displaydis=newDisplay(null);

dis.setVisible(true);

privatevoidqukuanActionPerformed(ActionEventevt){

Taketake=newTake(null);

take.setVisible(true);

privatevoidcunkuanActionPerformed(ActionEventevt){

Inputinput=newInput(null);

input.setVisible(true);

}

/*创建账户*/

publicclassAccount{

privateintcount=10000;

//初始账户余额10000

privateStringaccount="

1"

;

//初始账号

privateStringpassword="

//初始密码

publicAccount(){

publicvoidsetpw(Stringpassword){

this.password=password;

publicvoiddeccount(intmoney){

count-=money;

//取钱

publicvoidreccount(intmoney){

count+=money;

//存钱

publicintget(){

returncount;

publicStringgetaccount(){//账号

returnaccount;

publicStringgetpw(){

returnpassword;

importjava.awt.BorderLayout;

importjava.awt.GridLayout;

importjavax.swing.ImageIcon;

importjavax.swing.JLabel;

importjavax.swing.JPanel;

importjavax.swing.JTextField;

/*显示余额界面*/

publicclassDisplayextendsJFrame{

publicJButtonback;

privateJLabeljL1;

publicJTextFieldjT1;

AccountmyAccount;

//这个是便以传数值的

publicDisplay(Accountmyaccount){

this.myAccount=myaccount;

initComponents();

//初始化窗口,就是把窗口画出来

jT1.setText(String.valueOf(myaccount.get()));

//获得用户为标题

publicvoidset(Stringstr){

jT1.setText(str);

privatevoidinitComponents(){

jL1=newJLabel();

jT1=newJTextField(15);

quit=newJButton();

back=newJButton();

back.setIcon(newImageIcon("

xiaofangImage/back.png"

));

qukuan=newJButton();

qukuan.setIcon(newImageIcon("

xiaofangImage/qukuan.png"

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

jL1.setText("

您的余额为:

"

jL1.setIcon(newImageIcon("

xiaofangImage/money.png"

jT1.setEditable(false);

quit.setIcon(newImageIcon("

xiaofangImage/exit.png"

JPanelp1=newJPanel();

p1.add(jL1);

p1.add(jT1);

JPanelp2=newJPanel();

JPanelp3=newJPanel();

JPanelp4=newJPanel();

JPanelp5=newJPanel();

p3.add(qukuan);

p4.add(back);

p5.add(quit);

p2.setLayout(newGridLayout(3,1));

//把它分成3行1列

p2.add(p3);

p2.add(p4);

p2.add(p5);

this.getContentPane().add(p1,BorderLayout.NORTH);

//放在北方

this.getContentPane().add(p2,BorderLayout.CENTER);

//放在下面

this.setSize(300,270);

//以上是使用jpanel混合布局,三个JPanel分为3行1列,再把p1,放在北方,p2,放在下面

quit.addActionListener(newjava.awt.event.ActionListener(){//退出按钮的事件,只要点它,就关闭窗口了

publicvoidactionPerformed(java.awt.event.ActionEventevt){

quitActionPerformed(evt);

}

});

back.setText("

返回"

//返回按钮的事件,只要点它,就让当前的窗口不可见

back.addActionListener(newjava.awt.event.ActionListener(){

backActionPerformed(evt);

//取款按钮的事件

qukuan.addActionListener(newjava.awt.event.ActionListener(){

qukuanActionPerformed(evt);

newTake(myAccount);

//出现一个取款窗口,并让当前窗口不可见

privatevoidquitActionPerformed(ActionEventevt){

this.dispose();

//也是让自己不可见

privatevoidbackActionPerformed(ActionEventevt){

//当自己不可见

importjavax.swing.JOptionPane;

classInputextendsJFrame{

privateJButtonclear;

privateJButtoncommit;

privateJTextFieldjT1;

Stringstr="

privateAccountmyAccount;

publicInput(AccountmyAccount){

this.myAccount=myAccount;

this.setResizable(false);

commit=newJButton();

clear=newJButton();

存款金额:

commit.setText("

确认"

commit.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEventevt){

commitActionPerformed(evt);

clear.setText("

清除"

p2.add(commit);

p2.add(clear);

//分为2行1列

p3.setLayout(newGridLayout(2,1,20,30));

p3.add(p1);

p3.add(p2);

this.getContentPane().add(p3,BorderLayout.CENTER);

clear.addActionListener(newjava.awt.event.ActionListener(){

clearActionPerformed(evt);

privatevoidclearActionPerformed(ActionEventevt){

str="

privatevoidcommitActionPerformed(java.awt.event.ActionEventevt){

if(Integer.parseInt(jT1.getText())%100==0){

//数值不能是字符,必须是100的倍数

inta=Integer.parseInt(jT1.getText());

if(a<

0)

JOptionPane.showMessageDialog(null,"

存款不能为负数"

"

出错"

1);

else

myAccount.reccount(a);

intresult=javax.swing.JOptionPane.showConfirmDialog(null,

"

是否显示余额?

javax.swing.JOptionPane.YES_NO_OPTION,

javax.swing.JOptionPane.QUESTION_MESSAGE);

if(result==javax.swing.JOptionPane.YES_OPTION){

str="

jT1.setText(str);

newDisplay(myAccount);

this.setVisible(false);

}else{

newMainFrame();

}else{

JOptionPane.showMessageDialog(null,

存款金额必须为100的整数倍!

+"

\n请确认你的金额"

出错提示"

jT1.setText("

}

importjava.awt.event.Ac

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1