Closed Thread
Results 1 to 8 of 8

Thread: Verification Problem

  1. #1
    mosesff is offline Newbie
    Join Date
    Jun 2008
    Posts
    8
    Rep Power
    0

    Verification Problem

    Code:
    package BanqueDeux;
    
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.JTextField;
    
    public class HelloJava extends Applet
    {
    private JFrame frame = new JFrame("WelcomeToBarclaysBank");
    private JLabel label = new JLabel("Thank you, Welcome, Please Insert Your Card, If Finished Close Window", JLabel.LEFT);
    
    //Frame Size Changes and Writing on one individual frame including JLabels etc.
    private JButton clix = new JButton("EnterYourPIN");
    
    private JLabel j = new JLabel("-----------------------------------------------------------------------------------------------------------");
    
    private JButton une = new JButton("1");
    private JButton deux = new JButton("2");
    private JButton trois = new JButton("3");
    private JButton quatre = new JButton("4");
    private JButton cinq = new JButton("5");
    private JButton six = new JButton("6");
    private JButton sept = new JButton("7");
    private JButton huit = new JButton("8");
    private JButton neurfe = new JButton("9");
    private JButton zero = new JButton("0");
    
    private JTextField pinField = new JTextField(6);
    private JButton ui = new JButton("Enter");
    
    public HelloJava()
    {
    frame.getContentPane().add(label);
    
    add(clix);
    add(j);
    
    add(une);
    add(deux);
    add(trois);
    add(quatre);
    add(cinq);
    add(six);
    add(sept);
    add(huit);
    add(neurfe);
    add(zero);
    
    add(pinField);
    add(ui);
    
    //JButton declared for allow PIN Entry and an add of a JButton to the applet.
    clix.addActionListener 
    (
    new ActionListener() 
    {
    public void actionPerformed(ActionEvent e)
    {
    String title = "Barclays Banking";
    String pin = JOptionPane.showInputDialog("Please Enter Your PIN!");
    
    if(pin.equals("1111"))
    {
    String accnumbre = JOptionPane.showInputDialog("Enter your Account Number");
    
    if(accnumbre.equals("0072525"))
    {
    JOptionPane.showMessageDialog(null, "Entered Correct PIN and Account Number, Welcome");
    }
    }
    else if(pin.equals(""))
    {
    JOptionPane.showMessageDialog(null, "No PIN or AccNumbre Entered");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Wrong PIN or AccNumbre Entered");
    }
    }
    }
    );
    
    une.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(pinField.getText() + "1");
    }
    }
    );
    
    deux.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(deux.getText() + "2");
    }
    }
    );
    
    trois.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(trois.getText() + "3");
    }
    }
    );
    
    quatre.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(quatre.getText() + "4");
    }
    }
    );
    
    cinq.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(cinq.getText() + "5");
    }
    }
    );
    
    six.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(six.getText() + "6");
    }
    }
    );
    
    sept.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(sept.getText() + "7");
    }
    }
    );
    
    huit.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(huit.getText() + "8");
    }
    }
    );
    
    neurfe.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(neurfe.getText() + "9");
    }
    }
    );
    
    zero.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(zero.getText() + "0");
    }
    }
    );
    
    ui.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (pinField.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Your PIN is correct");
    setVisible(true);
    } else if(pinField.equals("")) {
    JOptionPane.showMessageDialog(null, "Nothing Entered");
    }
    }
    });
    
    frame.setSize(300, 300);
    frame.setVisible(true);
    }
    }
    Code:
    import java.applet.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.event.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    //Java AWT Declaration Eveents e.g. ActionEvent/Listener/Mouse
    import BanqueDeux.*;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    //importing another package and Different Buttons and Applets for Suitable Use.
    //Bibliogaphy/Bibliographie- JavaExamplesInANutshell- O-REILY
    //Bibliography/Bibliographie- Google- Search: AppletObjects
    public class BanqueATM extends Applet{
    
    public static Frame myFrame = new Frame();
    public static BanqueClass BC = new BanqueClass();
    //static frame and banque class declaration in addition to coding scope.
    
    Label greetingdeux = new Label("+++++BARCLAYS BANK+++++++-©- International =");
    Label greetingune = new Label("------------------------Ask a Banker For Your Pin-----------------------------");
    Label greeting = new Label("Welcome To Barclays Bank");
    Button clickButton = new Button("(PIN)-Click Here To Enter PIN");
    Label greetingtrois = new Label("***+++Withdraw Amount With Receipt+++++****");
    Button clique = new Button("Click");
    Label greetingjeur = new Label("**+++++++++Change Your PIN+++++++++++**");
    Button Buttoner = new Button("Confirm");
    Label grting = new Label("**++Print Mini Statementr++**");
    Button cliquedix = new Button("Print Statement");
    Label ecole = new Label("++++++++++**Withdraw With No Receipt***++++++++++");
    Button clinuyi = new Button("Click");
    Label fraisses = new Label("++++++View your current balance++++++");
    Button fraissesshow = new Button("View");
    Label f = new Label("--------------Return Card and Finish----------------");
    Button fo = new Button("Finish-ReturnCard");
    Label greetingx = new Label("-----------------------------------------------------");
    Label greetingg = new Label("------------------------------------------------");
    Label ifrancais = new Label("EMail a Banker at customerservices@barclays.co.uk");
    Label u = new Label("E-mail for programme help at '");
    Button almost = new Button("Help");
    //GUI Main Applet Graphics, Including Buttons, Labels etc, Text near is what is shown in Applet
    public void init() 
    {
    //Declaration of Main Display of Class
    setBackground(Color.lightGray);
    add(greetingdeux);
    add(greetingune);
    add(greeting);
    add(clickButton);
    add(greetingtrois);
    add(clique);
    add(greetingjeur);
    add(Buttoner);
    add(grting);
    add(cliquedix);
    add(ecole);
    add(clinuyi);
    add(fraisses);
    add(fraissesshow);
    add(f);
    add(fo);
    add(greetingx);
    add(greetingg);
    add(ifrancais);
    add(u);
    add(almost);
    //Adding Different Objects to the actual specific Class rather than
    //others
    
    Frame appletFrame = new Frame("PleaseRe-SizeWindowToEnterPIN");
    
    
    appletFrame.setLayout(new GridLayout(1,0));
    
    appletFrame.resize(500, 300);
    
    appletFrame.show();
    
    Applet HelloJava = new HelloJava();
    
    appletFrame.add(HelloJava);
    
    HelloJava.init();
    HelloJava.start();
    //Frames shown are resized and includes a joint applet to the main ATM class.
    cliquedix.addActionListener( new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    
    String title = "Barclays Banking";
    String message = "Thank you, Please Wait, Your Mini Statement is being Printed.";
    JOptionPane.showMessageDialog(null, message, title,
    JOptionPane.INFORMATION_MESSAGE);
    }
    });
    //An individual action Listener event which initiates on mouse click
    
    clickButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String title = "Barclays Banking";
    String pin = JOptionPane.showInputDialog("Please enter your PIN!");
    if (pin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Entered PIN: "+pin+". Welcome", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else if(pin.equals("")) {
    JOptionPane.showMessageDialog(null, "No PIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Entered");
    } 
    }
        });
    //An individual action Listener event which initiates on mouse clic
    clique.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpindeux = JOptionPane.showInputDialog("Enter PIN Before Withdrawing");
    if (enterpindeux.equals("1111")) {
    String cash = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount with Receipt: "+cash+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE); 
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    Buttoner.addActionListener(new ActionListener(){ 
    public void actionPerformed(ActionEvent e) {
    String changepin = JOptionPane.showInputDialog("What is your Old PIN? [ConsideringYourPreviousPINHasBeenEntered]");
    if (changepin.equals("1111")) {
    String newpin = JOptionPane.showInputDialog(null, "What is Your New PIN?");
    JOptionPane.showMessageDialog(null, "PIN Changed");
    } else if(changepin.equals("")) {
    JOptionPane.showMessageDialog(null, "NoPIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    clinuyi.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpin = JOptionPane.showInputDialog("Enter Your PIN Before Withdrawing");
    if (enterpin.equals("1111")) {
    String cashdeux = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw (w/o receipt)?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount without Receipt: "+cashdeux+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });  
    //An individual action Listener event which initiates on mouse click
    almost.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showMessageDialog(null, "Help Can be found at www.barclays.co.uk, customerservices@barclays.co.uk, Thank you");
    }
    }); //An individual action Listener event which initiates on mouse click
    //If and Else Statements included in all action Listeners.
    
    fraissesshow.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    double newAmount, initialAmount;
    newAmount = initialAmount = 20; 
        try {
            double withdrawelAmount = Double.parseDouble(JOptionPane.showInputDialog("How much have you withdrawn?"));
            newAmount = initialAmount - withdrawelAmount;
        } catch (NumberFormatException e) {
            System.err.println("That is not a number, Sir!");
            System.err.println("Transaction Void");
        } 
        JOptionPane.showMessageDialog(null, "You have: "+newAmount); 
    }
    });
    
    fo.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    String Carde = JOptionPane.showInputDialog(null, "Card Returned, Type PIN To Finish");
    if (Carde.equals("1111")) {
    setVisible(false);
    }
    }
    });
                        }  
                }
    (Above) This is my code.....

    This is the problem in the HelloJava class.......

    Code:
    ui.addActionListener(new ActionListener() {
    
    public void actionPerformed(ActionEvent e) {
    
    if (pinField.equals("1111")) {
    
    JOptionPane.showMessageDialog(null, "Your PIN is correct");
    
    setVisible(true);
    
    } else if(pinField.equals("")) {
    
    JOptionPane.showMessageDialog(null, "Nothing Entered");
    }
    
    }
    
    });
    When I run the problem code it compiles in the Hello Java class but does not allow for the numbers to be shown as correct or Incorrect or Nothing entered by an message input dialog, could someone help with why nothing is shown upon clicking the button and how I can make sure if I enter 1111 (the pin) or an incorrect PIN (2222) it tells me if its incorrect or correct.

    The PIN can be entered from clicking the JButtons I want it to verify if the numbers in the JTextField are correct or not by an InputDialog.

    Thank you.
    Last edited by mosesff; 06-28-2008 at 08:39 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    Re: Verification Problem

    When I have read some chapters in SICP I could check your problem okay?

  4. #3
    mosesff is offline Newbie
    Join Date
    Jun 2008
    Posts
    8
    Rep Power
    0

    Re: Verification Problem

    OK turk I look forward to your reply.

    Thanks Turk.
    Last edited by mosesff; 06-29-2008 at 06:59 AM.

  5. #4
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    Re: Verification Problem

    Well this wasn't easy to solve, I have done so much I can with it you have some imports I don't understand at all. First is this one "import BanqueDeux.*;"
    Also are you using Netbeans? It seems you have al ot of extra file imports that I can't reach...

    Well here is the stupid code...


    First part your pin thingy

    Code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.applet.*;
    import javax.swing.JTextField;
    
    public class pincode extends Applet
    {
    private JFrame frame = new JFrame("WelcomeToBarclaysBank");
    private JLabel label = new JLabel("Thank you, Welcome, Please Insert Your Card, If Finished Close Window", JLabel.LEFT);
    
    //Frame Size Changes and Writing on one individual frame including JLabels etc.
    private JButton clix = new JButton("EnterYourPIN");
    
    private JLabel j = new JLabel("-----------------------------------------------------------------------------------------------------------");
    
    private JButton une = new JButton("1");
    private JButton deux = new JButton("2");
    private JButton trois = new JButton("3");
    private JButton quatre = new JButton("4");
    private JButton cinq = new JButton("5");
    private JButton six = new JButton("6");
    private JButton sept = new JButton("7");
    private JButton huit = new JButton("8");
    private JButton neurfe = new JButton("9");
    private JButton zero = new JButton("0");
    
    private JTextField pinField = new JTextField(6);
    private JButton ui = new JButton("Enter");
    
    public pincode()
    {
    frame.getContentPane().add(label);
    
    add(clix);
    add(j);
    
    add(une);
    add(deux);
    add(trois);
    add(quatre);
    add(cinq);
    add(six);
    add(sept);
    add(huit);
    add(neurfe);
    add(zero);
    
    add(pinField);
    add(ui);
    
    //JButton declared for allow PIN Entry and an add of a JButton to the applet.
    clix.addActionListener 
    (
    new ActionListener() 
    {
    public void actionPerformed(ActionEvent e)
    {
    String pin = JOptionPane.showInputDialog("Please Enter Your PIN!");
    
    if(pin.equals("1111"))
    {
    String accnumbre = JOptionPane.showInputDialog("Enter your Account Number");
    
    if(accnumbre.equals("0072525"))
    {
    JOptionPane.showMessageDialog(null, "Entered Correct PIN and Account Number, Welcome");
    }
    }
    else if(pin.equals(""))
    {
    JOptionPane.showMessageDialog(null, "No PIN or AccNumbre Entered");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "No valid PIN");
    }
    }
    }
    );
    
    une.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(pinField.getText() + "1");
    }
    }
    );
    
    deux.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(deux.getText() + "2");
    }
    }
    );
    
    trois.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(trois.getText() + "3");
    }
    }
    );
    
    quatre.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(quatre.getText() + "4");
    }
    }
    );
    
    cinq.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(cinq.getText() + "5");
    }
    }
    );
    
    six.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(six.getText() + "6");
    }
    }
    );
    
    sept.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(sept.getText() + "7");
    }
    }
    );
    
    huit.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(huit.getText() + "8");
    }
    }
    );
    
    neurfe.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(neurfe.getText() + "9");
    }
    }
    );
    
    zero.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(zero.getText() + "0");
    }
    })
    ;}}
    Now for you own program...

    Code:
    import java.applet.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    //importing another package and Different Buttons and Applets for Suitable Use.
    //Bibliogaphy/Bibliographie- JavaExamplesInANutshell- O-REILY
    //Bibliography/Bibliographie- Google- Search: AppletObjects
    public class BanqueATM extends Applet{
    
    public static Frame myFrame = new Frame();
    public static BanqueATM BC = new BanqueATM();
    //static frame and banque class declaration in addition to coding scope.
    
    Label greetingdeux = new Label("+++++BARCLAYS BANK+++++++-©- International =");
    Label greetingune = new Label("------------------------Ask a Banker For Your Pin-----------------------------");
    Label greeting = new Label("Welcome To Barclays Bank");
    Button clickButton = new Button("(PIN)-Click Here To Enter PIN");
    Label greetingtrois = new Label("***+++Withdraw Amount With Receipt+++++****");
    Button clique = new Button("Click");
    Label greetingjeur = new Label("**+++++++++Change Your PIN+++++++++++**");
    Button Buttoner = new Button("Confirm");
    Label grting = new Label("**++Print Mini Statementr++**");
    Button cliquedix = new Button("Print Statement");
    Label ecole = new Label("++++++++++**Withdraw With No Receipt***++++++++++");
    Button clinuyi = new Button("Click");
    Label fraisses = new Label("++++++View your current balance++++++");
    Button fraissesshow = new Button("View");
    Label f = new Label("--------------Return Card and Finish----------------");
    Button fo = new Button("Finish-ReturnCard");
    Label greetingx = new Label("-----------------------------------------------------");
    Label greetingg = new Label("------------------------------------------------");
    Label ifrancais = new Label("EMail a Banker at customerservices@barclays.co.uk");
    Label u = new Label("E-mail for programme help at '");
    Button almost = new Button("Help");
    //GUI Main Applet Graphics, Including Buttons, Labels etc, Text near is what is shown in Applet
    @SuppressWarnings("deprecation")
    public void init() 
    {
    //Declaration of Main Display of Class
    setBackground(Color.lightGray);
    add(greetingdeux);
    add(greetingune);
    add(greeting);
    add(clickButton);
    add(greetingtrois);
    add(clique);
    add(greetingjeur);
    add(Buttoner);
    add(grting);
    add(cliquedix);
    add(ecole);
    add(clinuyi);
    add(fraisses);
    add(fraissesshow);
    add(f);
    add(fo);
    add(greetingx);
    add(greetingg);
    add(ifrancais);
    add(u);
    add(almost);
    //Adding Different Objects to the actual specific Class rather than
    //others
    
    Frame appletFrame = new Frame("PleaseRe-SizeWindowToEnterPIN");
    
    
    appletFrame.setLayout(new GridLayout(1,0));
    
    appletFrame.resize(500, 300);
    
    appletFrame.show();
    
    Applet HelloJava = new pincode();
    
    appletFrame.add(HelloJava);
    
    HelloJava.init();
    HelloJava.start();
    //Frames shown are resized and includes a joint applet to the main ATM class.
    cliquedix.addActionListener( new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    
    String title = "Barclays Banking";
    String message = "Thank you, Please Wait, Your Mini Statement is being Printed.";
    JOptionPane.showMessageDialog(null, message, title,
    JOptionPane.INFORMATION_MESSAGE);
    }
    });
    //An individual action Listener event which initiates on mouse click
    
    clickButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String pin = JOptionPane.showInputDialog("Please enter your PIN!");
    if (pin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Entered PIN: "+pin+". Welcome", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else if(pin.equals("")) {
    JOptionPane.showMessageDialog(null, "No PIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Entered");
    } 
    }
        });
    //An individual action Listener event which initiates on mouse click
    clique.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpindeux = JOptionPane.showInputDialog("Enter PIN Before Withdrawing");
    if (enterpindeux.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Correct Pin ");
    String cash = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount with Receipt: "+cash+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE); 
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    Buttoner.addActionListener(new ActionListener(){ 
    public void actionPerformed(ActionEvent e) {
    String changepin = JOptionPane.showInputDialog("What is your Old PIN? [ConsideringYourPreviousPINHasBeenEntered]");
    if (changepin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "PIN Changed");
    } else if(changepin.equals("")) {
    JOptionPane.showMessageDialog(null, "NoPIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    clinuyi.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpin = JOptionPane.showInputDialog("Enter Your PIN Before Withdrawing");
    if (enterpin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Correct Pin ");
    String cashdeux = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw (w/o receipt)?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount without Receipt: "+cashdeux+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });  
    //An individual action Listener event which initiates on mouse click
    almost.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showMessageDialog(null, "Help Can be found at www.barclays.co.uk, customerservices@barclays.co.uk, Thank you");
    }
    }); //An individual action Listener event which initiates on mouse click
    //If and Else Statements included in all action Listeners.
    
    fraissesshow.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    double newAmount, initialAmount;
    newAmount = initialAmount = 20; 
        try {
            double withdrawelAmount = Double.parseDouble(JOptionPane.showInputDialog("How much have you withdrawn?"));
            newAmount = initialAmount - withdrawelAmount;
        } catch (NumberFormatException e) {
            System.err.println("That is not a number, Sir!");
            System.err.println("Transaction Void");
        } 
        JOptionPane.showMessageDialog(null, "You have: "+newAmount); 
    }
    });
    
    fo.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    String Carde = JOptionPane.showInputDialog(null, "Card Returned, Type PIN To Finish");
    if (Carde.equals("1111")) {
    setVisible(false);
    }
    }
    });
                        }  
                }
    If it isn't what you wanted tell me and explain a bit more please?

  6. #5
    mosesff is offline Newbie
    Join Date
    Jun 2008
    Posts
    8
    Rep Power
    0

    Re: Verification Problem

    Quote Originally Posted by Turk4n View Post
    Well this wasn't easy to solve, I have done so much I can with it you have some imports I don't understand at all. First is this one "import BanqueDeux.*;"
    Also are you using Netbeans? It seems you have al ot of extra file imports that I can't reach...

    Well here is the stupid code...


    First part your pin thingy

    Code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.applet.*;
    import javax.swing.JTextField;
    
    public class pincode extends Applet
    {
    private JFrame frame = new JFrame("WelcomeToBarclaysBank");
    private JLabel label = new JLabel("Thank you, Welcome, Please Insert Your Card, If Finished Close Window", JLabel.LEFT);
    
    //Frame Size Changes and Writing on one individual frame including JLabels etc.
    private JButton clix = new JButton("EnterYourPIN");
    
    private JLabel j = new JLabel("-----------------------------------------------------------------------------------------------------------");
    
    private JButton une = new JButton("1");
    private JButton deux = new JButton("2");
    private JButton trois = new JButton("3");
    private JButton quatre = new JButton("4");
    private JButton cinq = new JButton("5");
    private JButton six = new JButton("6");
    private JButton sept = new JButton("7");
    private JButton huit = new JButton("8");
    private JButton neurfe = new JButton("9");
    private JButton zero = new JButton("0");
    
    private JTextField pinField = new JTextField(6);
    private JButton ui = new JButton("Enter");
    
    public pincode()
    {
    frame.getContentPane().add(label);
    
    add(clix);
    add(j);
    
    add(une);
    add(deux);
    add(trois);
    add(quatre);
    add(cinq);
    add(six);
    add(sept);
    add(huit);
    add(neurfe);
    add(zero);
    
    add(pinField);
    add(ui);
    
    //JButton declared for allow PIN Entry and an add of a JButton to the applet.
    clix.addActionListener 
    (
    new ActionListener() 
    {
    public void actionPerformed(ActionEvent e)
    {
    String pin = JOptionPane.showInputDialog("Please Enter Your PIN!");
    
    if(pin.equals("1111"))
    {
    String accnumbre = JOptionPane.showInputDialog("Enter your Account Number");
    
    if(accnumbre.equals("0072525"))
    {
    JOptionPane.showMessageDialog(null, "Entered Correct PIN and Account Number, Welcome");
    }
    }
    else if(pin.equals(""))
    {
    JOptionPane.showMessageDialog(null, "No PIN or AccNumbre Entered");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "No valid PIN");
    }
    }
    }
    );
    
    une.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(pinField.getText() + "1");
    }
    }
    );
    
    deux.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(deux.getText() + "2");
    }
    }
    );
    
    trois.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(trois.getText() + "3");
    }
    }
    );
    
    quatre.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(quatre.getText() + "4");
    }
    }
    );
    
    cinq.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(cinq.getText() + "5");
    }
    }
    );
    
    six.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(six.getText() + "6");
    }
    }
    );
    
    sept.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(sept.getText() + "7");
    }
    }
    );
    
    huit.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(huit.getText() + "8");
    }
    }
    );
    
    neurfe.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(neurfe.getText() + "9");
    }
    }
    );
    
    zero.addActionListener
    (
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    pinField.setText(zero.getText() + "0");
    }
    })
    ;}}
    Now for you own program...

    Code:
    import java.applet.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    //importing another package and Different Buttons and Applets for Suitable Use.
    //Bibliogaphy/Bibliographie- JavaExamplesInANutshell- O-REILY
    //Bibliography/Bibliographie- Google- Search: AppletObjects
    public class BanqueATM extends Applet{
    
    public static Frame myFrame = new Frame();
    public static BanqueATM BC = new BanqueATM();
    //static frame and banque class declaration in addition to coding scope.
    
    Label greetingdeux = new Label("+++++BARCLAYS BANK+++++++-©- International =");
    Label greetingune = new Label("------------------------Ask a Banker For Your Pin-----------------------------");
    Label greeting = new Label("Welcome To Barclays Bank");
    Button clickButton = new Button("(PIN)-Click Here To Enter PIN");
    Label greetingtrois = new Label("***+++Withdraw Amount With Receipt+++++****");
    Button clique = new Button("Click");
    Label greetingjeur = new Label("**+++++++++Change Your PIN+++++++++++**");
    Button Buttoner = new Button("Confirm");
    Label grting = new Label("**++Print Mini Statementr++**");
    Button cliquedix = new Button("Print Statement");
    Label ecole = new Label("++++++++++**Withdraw With No Receipt***++++++++++");
    Button clinuyi = new Button("Click");
    Label fraisses = new Label("++++++View your current balance++++++");
    Button fraissesshow = new Button("View");
    Label f = new Label("--------------Return Card and Finish----------------");
    Button fo = new Button("Finish-ReturnCard");
    Label greetingx = new Label("-----------------------------------------------------");
    Label greetingg = new Label("------------------------------------------------");
    Label ifrancais = new Label("EMail a Banker at customerservices@barclays.co.uk");
    Label u = new Label("E-mail for programme help at '");
    Button almost = new Button("Help");
    //GUI Main Applet Graphics, Including Buttons, Labels etc, Text near is what is shown in Applet
    @SuppressWarnings("deprecation")
    public void init() 
    {
    //Declaration of Main Display of Class
    setBackground(Color.lightGray);
    add(greetingdeux);
    add(greetingune);
    add(greeting);
    add(clickButton);
    add(greetingtrois);
    add(clique);
    add(greetingjeur);
    add(Buttoner);
    add(grting);
    add(cliquedix);
    add(ecole);
    add(clinuyi);
    add(fraisses);
    add(fraissesshow);
    add(f);
    add(fo);
    add(greetingx);
    add(greetingg);
    add(ifrancais);
    add(u);
    add(almost);
    //Adding Different Objects to the actual specific Class rather than
    //others
    
    Frame appletFrame = new Frame("PleaseRe-SizeWindowToEnterPIN");
    
    
    appletFrame.setLayout(new GridLayout(1,0));
    
    appletFrame.resize(500, 300);
    
    appletFrame.show();
    
    Applet HelloJava = new pincode();
    
    appletFrame.add(HelloJava);
    
    HelloJava.init();
    HelloJava.start();
    //Frames shown are resized and includes a joint applet to the main ATM class.
    cliquedix.addActionListener( new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    
    String title = "Barclays Banking";
    String message = "Thank you, Please Wait, Your Mini Statement is being Printed.";
    JOptionPane.showMessageDialog(null, message, title,
    JOptionPane.INFORMATION_MESSAGE);
    }
    });
    //An individual action Listener event which initiates on mouse click
    
    clickButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String pin = JOptionPane.showInputDialog("Please enter your PIN!");
    if (pin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Entered PIN: "+pin+". Welcome", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else if(pin.equals("")) {
    JOptionPane.showMessageDialog(null, "No PIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Entered");
    } 
    }
        });
    //An individual action Listener event which initiates on mouse click
    clique.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpindeux = JOptionPane.showInputDialog("Enter PIN Before Withdrawing");
    if (enterpindeux.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Correct Pin ");
    String cash = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount with Receipt: "+cash+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE); 
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    Buttoner.addActionListener(new ActionListener(){ 
    public void actionPerformed(ActionEvent e) {
    String changepin = JOptionPane.showInputDialog("What is your Old PIN? [ConsideringYourPreviousPINHasBeenEntered]");
    if (changepin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "PIN Changed");
    } else if(changepin.equals("")) {
    JOptionPane.showMessageDialog(null, "NoPIN Entered");
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });
    //An individual action Listener event which initiates on mouse click
    clinuyi.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    String enterpin = JOptionPane.showInputDialog("Enter Your PIN Before Withdrawing");
    if (enterpin.equals("1111")) {
    JOptionPane.showMessageDialog(null, "Correct Pin ");
    String cashdeux = JOptionPane.showInputDialog("How Much Cash Would You Like To Withdraw (w/o receipt)?");
    JOptionPane.showMessageDialog(null, "Withdrawing the following amount without Receipt: "+cashdeux+". Amount Withdrawing", "Barclays", JOptionPane.INFORMATION_MESSAGE);
    } else {
    JOptionPane.showMessageDialog(null, "Wrong PIN Sir/Madam");
    }
    }
    });  
    //An individual action Listener event which initiates on mouse click
    almost.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showMessageDialog(null, "Help Can be found at www.barclays.co.uk, customerservices@barclays.co.uk, Thank you");
    }
    }); //An individual action Listener event which initiates on mouse click
    //If and Else Statements included in all action Listeners.
    
    fraissesshow.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    double newAmount, initialAmount;
    newAmount = initialAmount = 20; 
        try {
            double withdrawelAmount = Double.parseDouble(JOptionPane.showInputDialog("How much have you withdrawn?"));
            newAmount = initialAmount - withdrawelAmount;
        } catch (NumberFormatException e) {
            System.err.println("That is not a number, Sir!");
            System.err.println("Transaction Void");
        } 
        JOptionPane.showMessageDialog(null, "You have: "+newAmount); 
    }
    });
    
    fo.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    String Carde = JOptionPane.showInputDialog(null, "Card Returned, Type PIN To Finish");
    if (Carde.equals("1111")) {
    setVisible(false);
    }
    }
    });
                        }  
                }
    If it isn't what you wanted tell me and explain a bit more please?
    Turk Import Banque Deux is a seperate package which contains my 2nd HelloJava class.

    I think for now I will leave this coding, but just to explain I wanted the PIN to be verified as correct or incorrect in other words to 'compare the textfield with a number' if it is incorrect or not.

  7. #6
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    Re: Verification Problem

    Sure, I made the code to tell if its correct or wrong so no problem I guess or?

  8. #7
    mosesff is offline Newbie
    Join Date
    Jun 2008
    Posts
    8
    Rep Power
    0

    Re: Verification Problem

    I think there needed to be an action listener for UI (this UI is the JButton) and it is a difficult problem to solve, it needed an action listener a string to compare like string doo = textfield.getText()
    if(doo.equals(1111)
    JOptionPane

    I am not sure you wrote this but I think that was the solution, but thank you for indenting my code and showing me the imports were wrong, because it was. GUI on Java is hard.

  9. #8
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    Re: Verification Problem

    Okay, glad I could help you

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. username and password verification
    By ravi951 in forum PHP Development
    Replies: 4
    Last Post: 08-21-2011, 01:27 PM
  2. Float Value Verification
    By howejustin in forum C and C++
    Replies: 9
    Last Post: 01-15-2009, 05:43 PM
  3. PHP:Tutorial - Email Verification
    By John in forum PHP Tutorials
    Replies: 3
    Last Post: 09-19-2007, 10:19 AM
  4. Email Verification
    By Lop in forum PHP Development
    Replies: 7
    Last Post: 12-22-2006, 08:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts