?? javaatm.txt
字號(hào):
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("請按相關(guān)按鈕操作",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); } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -