How to check JTextField text to String?

Since your question is not very clear, I suggest these answers: 1st option - you want to get string from your JTextField: String text = txtGuessPad.getText() 2nd option - you want to check if text contains only letter: String text = txtGuessPad.getText(); if(text. Matches("^a-zA-Z+$")){ 3rd option - you want to compare two strings (one of them is from JTextField): String text = txtGuessPad.getText(); String text2 = "test"; if(text. Equals(text2)){... //if you want to match whole word and case sensitive if(text.

EqualsIgnoreCase(text2)){... //if you want to match whole word and NOT case sensitive if(text. StartsWith(text2)){... //if you want to check if you string starts with other string 4th option - let's put it in a function: public boolean isEqualToString(JTextField textField, String compareTo) { String text = textField.getText(); if(text. Equals(compareTo)) { return true; } return false; }.

Since your question is not very clear, I suggest these answers: 1st option - you want to get string from your JTextField: String text = txtGuessPad.getText(); 2nd option - you want to check if text contains only letter: String text = txtGuessPad.getText(); if(text. Matches("^a-zA-Z+$")){... 3rd option - you want to compare two strings (one of them is from JTextField): String text = txtGuessPad.getText(); String text2 = "test"; if(text. Equals(text2)){... //if you want to match whole word and case sensitive if(text.

EqualsIgnoreCase(text2)){... //if you want to match whole word and NOT case sensitive if(text. StartsWith(text2)){... //if you want to check if you string starts with other string 4th option - let's put it in a function: public boolean isEqualToString(JTextField textField, String compareTo) { String text = textField.getText(); if(text. Equals(compareTo)) { return true; } return false; }.

Public class SubmitHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ String text = txtGuessPad.getText(); String text2 = answer; int score = 10; if(text. EqualsIgnoreCase(text2)){ txtscore. SetText(score);}//error here :( } } – lver Bomb Sep 22 at 11:05 Got it thanks men.. – lver Bomb Sep 22 at 11:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send