Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Java simple login function not working

  1. #1
    Member
    Join Date
    Sep 2012
    Posts
    30
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Java simple login function not working

    Hello there
    i have this simple login function where i compare what you write with what is in the array and if it is the same it will open a new window else nothing will happen but it doesn't seem to work :/
    can someone please help me what is wrong with my code?
          login.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
    		String[] usernameArray={"User1","User2","User3"}; 	//array where i save file username and a other one for password
          String[] passwordArray={"Pass1","Pass2","Pass3"};
     
    			for (int i=0; i<usernameArray.length; i++){							// make a for loop so it tjeks all the different users
    			if((usernameField.equals(usernameArray[i]) && passwordField.equals(passwordArray[i]))){
    				JOptionPane.showMessageDialog(null,"Welcome "+usernameField+"\n"+"You are logged in");
    				login.addActionListener(new login());
    				dialog.setVisible(false);
                frame.setVisible(false);
    			}
     
             }															// end of for loop 
          }
    		});


  2. #2
    Member vigneshwaran's Avatar
    Join Date
    Nov 2012
    Location
    Chennai, TamilNadu
    Posts
    35
    My Mood
    Cheerful
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Java simple login function not working

    Argument size was increased in Message Dialogue Box

  3. #3
    Member
    Join Date
    Sep 2012
    Posts
    30
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Java simple login function not working

    Quote Originally Posted by vigneshwaran View Post
    Argument size was increased in Message Dialogue Box
    and what does that mean?

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Java simple login function not working

    Quote Originally Posted by vigneshwaran View Post
    Argument size was increased in Message Dialogue Box
    Mind telling me how?


    @vigneshwaran: You need to read about what addActionListener does. You are no where calling the new GUI to display.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  5. The Following User Says Thank You to Mr.777 For This Useful Post:

    vigneshwaran (November 28th, 2012)

  6. #5
    Member
    Join Date
    Sep 2012
    Posts
    30
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Java simple login function not working

    don't i do that with
    login.addActionListener(new login());

    or is that just me that is wrong? because i can make it work if i take it out of the login method there then it works butn when i put it in the login method it doesn't wanna open the new window or anything :/

  7. #6
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Java simple login function not working

    Quote Originally Posted by lf2killer View Post
    don't i do that with
    login.addActionListener(new login());

    or is that just me that is wrong? because i can make it work if i take it out of the login method there then it works butn when i put it in the login method it doesn't wanna open the new window or anything :/
    Yeah please read about what addActionListener does. You will get your answer.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

Similar Threads

  1. Simple computer login problem
    By centralnathan in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: November 1st, 2012, 03:55 PM
  2. Working with log math function
    By colerelm in forum Object Oriented Programming
    Replies: 0
    Last Post: October 15th, 2012, 06:30 PM
  3. Login / Logout Session | why it isn't working?
    By sadaharu in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 22nd, 2012, 03:46 AM
  4. i need coding for simple login
    By nag in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: September 29th, 2011, 02:30 PM
  5. simple login web service
    By mr_aliagha in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: January 5th, 2010, 03:49 PM