Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

something weird on some JComponents...  RSS feed

 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now at the part of writing the code in authenticating the user log in of my program...
i am using JTextField and JPasswordField on getting inputs and JOptionPane as my message prompt...

Here's my code...



I have the System.out part to check if it is working and here is what it shows up on the output pane of netbeans IDE...

From Password Field:[C@1de0b5e
From Database:[C@bc5596


i tried to interchange some of the things because it keeps on popping Error in validating user whereas i am entering the same username and password from the database...

admin & admin...

i also tried to this one...



and got this result


From Password Field:[C@17e4dee
From Database:admin


i also tried the deprecated JPasswordField.getText();



and still it pops out the Error in validating user error message.. :O
any idea about this, guys? thanks in advance.
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never use "==" to compare objects. Use the equals(...) method.
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Never use "==" to compare objects. Use the equals(...) method.


it still produces the same output as before..
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Have you read the API? The method getText() is deprecated.

2) Have you printed out the values to make sure you get what you expect?

3) Have you trimmed the values to make sure there are not spaces.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

And that does not mean including you SQL code. You create a simple GUI with a JPasswordField and hardcode the password. Once you get that working you use the knowledge you gained from the SSCCE and add it to your real program.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
I corrected a small typo in your previous post. I presume you meant getText() is deprecated instead of getPassword()

Jhedzkie,
Check out the API to see what getPassword() actuall returns.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jhedzkie Skies wrote:

From Password Field:[C@1de0b5e
From Database:[C@bc5596

That's exactly how arrays are printed: a [ to indicate it is an array, next the element type (where C means char), then an @ and then the HEX representation of the hash code. You can use new String(array) to create a String from a char[].
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!