Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:27:29+00:00 2026-06-01T03:27:29+00:00

My program takes user name and password authentication from user before initialising the program,

  • 0

My program takes user name and password authentication from user before initialising the program,
so i created a button login to which i associated ActionListener as show below

   login.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent event){
                if(txtUserName.getText().equals("Suraj") && (txtPwd.getPassword().toString()).equals("s123")){

                                dispose();
                                TimeFrame tFrame = new TimeFrame(userName);
                                tFrame.setVisible(true);
                                tFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                                tFrame.setLayout(new GridLayout());

                        } else {
                            JOptionPane.showMessageDialog(null,"User name or password don't match","Acces Denied", JOptionPane.ERROR_MESSAGE);
                        }

Now the problem that occurs is even if i enter correct password, program displays an error mesenter image description heresage

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:27:31+00:00Added an answer on June 1, 2026 at 3:27 am

    getPassword() returns a char[]. The toString() on it does not return the contents as a string as you assume.

    Try new String(txtPwd.getPassword()).equals("s123").

    However, there is a reason it is a char[] and not a String. Try looking up the security aspect of it in the javadoc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program in which the user needs to login with user name
I'm making a program that takes names from the user seperated by commas. The
In a nutshell what my program does is: it executes and takes user input
My C/C++ program takes a file from the command line as an argument. Reading
I have a program which takes a long time to complete. I would like
I've got a program that takes 3 arrays (which are the same length, can
I am trying to use a Stored Procedure which takes two parameters (login, pw)
I have a program that takes data from an excel file and manipulates it
I am making a basic program which takes some input and prints it back
I have a following program, it takes strings from 4 textboxes and puts them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.