⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javaatm.txt

📁 ATM的一些问题
💻 TXT
字号:
package ATM;

import java.awt.*; import java.awt.event.*;

public class AtmDialog { public static void main(String args[]) { MyDialogFrame df=new MyDialogFrame(); } }

@SuppressWarnings("serial")
class MyDialogFrame extends Frame implements ActionListener,ComponentListener { Dialog MegDlg,InOutDlg; Label prompt; Label prompt1; Button btn1,btn2,btn3,btn4,btn5; TextField tf=new TextField("请按相关按钮操作",25); TextField getMeg=new TextField("您目前的存款是1000元. 2004-11-22",10); TextField getMeg1=new TextField(20); MyDialogFrame() { super("ATM终端"); prompt=new Label("欢迎您的光临!"); btn1=new Button("取款"); btn2=new Button("查询");

btn3=new Button("确定"); btn4=new Button("取消"); btn5=new Button("返回"); setLayout(new FlowLayout()); add(prompt); add(tf); add(btn1); add(btn2); //add(btn3); //btn1.addComponentListener(this); getMeg1.addActionListener(this); btn1.addActionListener(this); btn2.addActionListener(this); //btn3.addActionListener(this); btn3.addActionListener(this); btn4.addActionListener(this); btn5.addActionListener(this); setSize(350,150); show(); } public void actionPerformed(ActionEvent e) { 

Button e = null;
if(e.getActionCommand()=="取款") { MegDlg=new Dialog(this,"请输入取款金额",true); Panel p1=new Panel(); MegDlg.add("Center",getMeg1); Panel p2=new Panel(); p2.add(btn3); p2.add(btn4); MegDlg.add("South",p2); MegDlg.setSize(200,100); MegDlg.show(); } else if(e.getActionCommand()=="查询") { InOutDlg=new Dialog(this); InOutDlg.add("Center",getMeg); InOutDlg.add("South",btn5); InOutDlg.setSize(200,100); InOutDlg.show(); } else if(e.getActionCommand()=="确定") { tf.setText("请取走金额..."); getMeg.setText("您的帐户余额为:(1000-"+getMeg1.getText()+")元"); MegDlg.dispose(); } // else if(getMeg1.getText()<getMeg.getText())

else if(e.getActionCommand()=="取消") MegDlg.dispose(); else if(e.getActionCommand()=="返回") { InOutDlg.dispose(); } } public void componentShown(ComponentEvent e){} public void componentResized(ComponentEvent e){} public void componentMoved(ComponentEvent e){} public void componentHidden(ComponentEvent e){}

public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	
}

}

class WinAdpt extends WindowAdapter { public void windowClosing(WindowEvent e) { ((Frame)e.getWindow()).dispose(); System.exit(0); } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -