Code :username = new JTextField(10); add(username);
Code :password = new JTextField(10); add( password );
Code :if(username.getText() = "_____" + password.getText() == "______" )
Printable View
Code :username = new JTextField(10); add(username);
Code :password = new JTextField(10); add( password );
Code :if(username.getText() = "_____" + password.getText() == "______" )
This is very vague to me. Could you post some guidance, as I don't really know what you want to do?
Also, I did notice that this is problematic...
if(username.getText() = "_____" + password.getText() == "______" )
What are you doing here? The statement...
username.getText() = "_____" + password.getText()
...will not work, as what you are doing here is telling Java to assign the value of "_____" + password.getText() to username.getText(), which is impossible. Methods do not work like that. Please, explain what you are trying to do, then I might be able to help better.
There are several things that need to be changed:
For "and" meaning "this as well as that" we use && not +. (+ is either an arithmetic operator meaning "added to", or a string concatenation operator meaning "joined on to". It already has enough to do!)
= and == do totally different things. = assigns the value of the expression on the right hand side to the variable on the left hand side. ==, on the other hand means "is the same as". Except...
When you are comparing objects, don't use ==. Use equals() instead. (== actually compares references values for equality, while .equals() is a method that any class can override to report whether objects should be considered the same. Don't worry about this - just use equals() to test for equality.)
Code :if(username.getText().equals("foo")) { // etc
-----
Refer to your textbooks etc for basic syntax. Or Oracle's Tutorial. If you can't understand a compiler message it pays to post both the code and the complete message. Generally these messages are very useful so it is worth finding out what they mean, rather than concentrating just on how to fix some specific problem.
You're welcome.