Java GUI if/else issue?
personal boolean checkNumber()
in case (textPhone.startsWith(“972”) textPhone.startsWith(“214”))
labelPhone.setForeground(Color.BLACK);
return true;
different
labelPhone.setForeground(Color.RED);
return false;
this challenge is part of a GUI enrollment form for a project im working on
and I’d be pleased if anyone could assist me out keeping this, basically im attempting to say in case whatever variety i accessed in about the GUI starts which includes a 972, or 214 masters without issues…anything else returns untrue and don’t work, the textPhone may be the text field belonging to the GUI, if there’s a healthier way of achieving this please really feel free to express, thanks pertaining to reading the following, and every help is definitely appreciated!
can anyone tell that which is textPhone
will it be a stringed or anything else
check out your earlier question
+add
well if it is a number along with its datatype is int then
String phone=Integer.toString(textPhone);
currently in if condition fit phone
as opposed to textPhone
It appears fine to my opinion.I really don’t see some other obvious way of doing what you’re looking to do.What is a the problem
Edit:
Very well, just like the error message says, textPhone doesn’t use a startsWith() method.Obviously textPhone just isn’t a Chain, but you’re attempting to use the idea as if it were one.What is the type associated with textPhone Everyone say “so it’d be the number”, but “number” just isn’t a key in Java.If you can’t figure available what the kind of textPhone is yourself, could you post this code where it’s declared.
Leave a Reply
You must be logged in to post a comment.