Hi lads,
Just wondering how I can take in the text from an array of JTextFields and check to see if their values are not = to "X" .
So far my code is :
nextPlayer is a buttonCode:public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("nextP… count++; if(count == 1 || count == 3 || count == 5 || count == 7 || count == 9){ while (a<b){ if(text[a].getText() != "X"){ JOptionPane.showMessageDialog(nu… "Must use X only"); } } }
and the while a<b is just a loop to go through the array of text fields called text[]
Thanks,
Disco
You should just use the logical not operator ( ! ), and apply it to see if text[a] is equal to "X".
Code:if (!text[a].getText().equals("X")) { JOptionPane.showMessageDialog(nu..., "Must use X only."); }
Wow I changed my sig!
Thanks for your reply mate , but its still accepting letters that are not X . Any other ideas... This stuff is stressing me out at this stage ...
Thanks,
Disco
Is it showing the JOptionPane properly? That's all that program should do, show a JOptionPane, since it's not sending any "rejection" code or performing any other action that would cause the user to be unable to input anything other than X. I think you're the only one who can pull that off since you know your code better than I.
If you have the code that executes by pressing the button after this loop and you don't want that code to execute, you just need to return; there.
Wow I changed my sig!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks