JAVA Retarded ATM

Source: Internet
Author: User
Tags gettext

Idle to have nothing to do, knock to play.



Code:

Package Atm;import java.awt.*;import java.awt.event.*;import javax.swing.*;p ublic class ATM extends JFrame implements  ActionListener {private JPanel pan; private JPanel sec; private JButton log; static JLabel text1=new JLabel ("account"); static JLabel text2=new JLabel ("password"); Static JLabel text3=new JLabel ("deposit"); Static JLabel text4=new JLabel ("withdrawals"); Static JLabel text5=new JLabel ("balance"); Static JTextField account=new JTextField ("", 18); Static JTextField password=new JTextField ("", 18); Static JTextField savein=new JTextField ("", 12); Static JButton saveb=new JButton ("confirmation"); Static JTextField takeout=new JTextField ("", 12); Static JButton takeb=new JButton ("confirmation"); Static JTextField left=new JTextField ("", 12); static int money=10000; String zero=integer.tostring (0); String Acc=new string ("888888"); String Pas=new string ("888888");  ATM () {this.setbounds (400, 300, 260, 200);  Pan = new JPanel ();  Log = new JButton ("login");  Log.addactionlistener (this);  This.add (PAN);  This.setalwaysontop (TRUE); ThiS.setvisible (TRUE);  Pan.add (Text1);  Pan.add (account);  Pan.add (TEXT2);  Pan.add (password);  Pan.add (log); This.settitle ("ATM");} public static void Main (String args[]) {new ATM ()}, public void actionperformed (ActionEvent e) {if (E.getsource () ==lo g) {String ac=account.gettext ();        String Pa=password.gettext (); if (Ac.equals (ACC) &&pa.equals (PAS)) {this.setvisible (false);    New another ();    }}}class another extends jframe{another () {sec = new JPanel ();        This.add (SEC);        This.settitle ("ATM");        This.setbounds (400, 300, 260, 200);        This.setvisible (TRUE);        Sec.add (TEXT3);        Sec.add (Savein);        Sec.add (SAVEB);        Sec.add (TEXT4);        Sec.add (takeout);        Sec.add (TAKEB);        Sec.add (TEXT5);        Sec.add (left); String m=integer.tostring (Money); Left.settext (M); left.seteditable (false); Savein.settext (zero); Takeout.settext (        zero); Saveb.addactionlistener (new ActionListener () {public void actionperformed(ActionEvent e) {String tmp=savein.gettext (); int val=integer.parseint (TMP); Savein.settext (zero); Takeout.settext (zero); if (val> 0) {money+=val; String m=integer.tostring (Money); Left.settext (M); left.seteditable (false); Joptionpane.showmessagedialog (NULL, "Deposit successful! "); } Else{joptionpane.showmessagedialog (NULL, "You Tease me!"        "); }}}); Takeb.addactionlistener (new ActionListener () {public void actionperformed (ActionEvent e) {String Tmp=takeout.gettext ( ); int val=integer.parseint (TMP); Savein.settext (zero); Takeout.settext (zero); if (val>=0 && Val<=money && val%100==0) {money-=val; String m=integer.tostring (Money); Left.settext (M); left.seteditable (false); Joptionpane.showmessagedialog (NULL, "successful withdrawals!  "); }else{joptionpane.showmessagedialog (NULL, "illegal operation! "); }}});     }}}


JAVA Retarded ATM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.