Results 1 to 3 of 3
  1. #1
    Chick786 is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default Annoying problem class/interface error

    please ignore this thread. sorryl
    Last edited by Chick786; 04-11-2010 at 04:13 PM.

  2. #2
    Cemi's Avatar
    Cemi is offline Member
    Join Date
    Apr 2010
    Posts
    36
    Rep Power
    0

    Default

    I believe you need to put it inside you class. You can't have the main method outside of the class :)

    So put it in before the ending } of your "public class CashMachine extends JPanel {"
    Carpe Diem
    Each day's a gift and not a given right

  3. #3
    Chick786 is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    public class JPassword {
    private String password = "pass";
    private void main() {
    //create frame
    JFrame frame = new JFrame("Password");
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.setSize(400,100);

    JLabel label3 = new JLabel("Enter Pin Code");
    JPanel panel = new JPanel();
    frame.add(panel);

    JPasswordField pass = new JPasswordField(5);
    pass.setEchoChar('*');
    pass.addActionListener(new AL());
    panel.add(label3, BorderLayout.WEST);
    panel.add(pass, BorderLayout.WEST);

    }


    private class AL implements ActionListener{

    public void actionPerformed(ActionEvent e){
    JPasswordField input = (JPasswordField) e.getSource();
    char[] passy = input.getPassword();
    String p = new String(passy);

    if (p.equals(password)){
    JOptionPane.showMessageDialog(null, "Correct");
    }
    else
    JOptionPane.showMessageDialog(null, "Incorrect");
    }
    }
    }

    I've basically done that..

    It's not throwing a hissy fit on bluej now, but i'll just finish off the code and see what happens.

    Thank you for your help.

Similar Threads

  1. Replies: 13
    Last Post: 02-20-2010, 07:56 PM
  2. Insanely annoying java error...
    By Nukleahboy in forum New To Java
    Replies: 10
    Last Post: 08-07-2009, 09:22 AM
  3. Replies: 14
    Last Post: 05-28-2009, 05:44 AM
  4. Annoying database problem!
    By DC1 in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 09:43 AM
  5. Replies: 0
    Last Post: 04-02-2008, 07:04 AM

Posting Permissions

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