Results 1 to 6 of 6
Thread: more help with my applet
- 04-07-2009, 04:57 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 11
- Rep Power
- 0
more help with my applet
this is for hangman
why doesnt this add wrong letters to wrong letter field eventhough it should?
i attached a pic of the GUI
Java Code:private void guessButtonActionPerformed(java.awt.event.ActionEvent evt) { guess = letterEnter.getText(); boolean letterCorrect = false; if (guess.length()>1) //checks to see if the guess is only 1 char long { letterEnter.setText(""); } else { for (int i = 0; i<=correctWord.length()-1; i++) // compares guessletter with every letter in correct word { String tester = correctWord.substring(i,i+1); //System.out.println(guess+"hi"); if (guess.equals(tester)) { letterCorrect = true; correctSpot1.setText(guess); break; } else if (letterCorrect = false) { System.out.println("aa"); wrongLetterField.setText(wrongLetterField.getText()+letterEnter.getText()); } } } } private void setCorrectWordActionPerformed(java.awt.event.ActionEvent evt) { correctWord = wordEnter.getText(); }
- 04-07-2009, 03:06 PM #2
Don't know if it will fix the problem your seeing, but you have an error in the following:
You're doing an assignment... not a comparation. It should be as follows:Java Code:if (letterCorrect [B][COLOR="Red"]=[/COLOR][/B] false)
Luck,Java Code:if (letterCorrect [B][COLOR="Blue"]==[/COLOR][/B] false)
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
-
Or better yet,
Java Code:if (!letterCorrect)
- 04-24-2009, 10:41 AM #4
Member
- Join Date
- Apr 2009
- Posts
- 10
- Rep Power
- 0
Thats very nice
- 04-25-2009, 01:50 AM #5
so solved?
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-25-2009, 02:05 AM #6
Member
- Join Date
- Apr 2009
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
3D Applet
By DzzD in forum Java AppletsReplies: 1Last Post: 03-30-2009, 11:20 PM -
Calling another applet on click of button in one applet
By niteshwar.bhardwaj in forum Java 2DReplies: 1Last Post: 02-19-2009, 12:54 PM -
Need with an applet
By maggie_2 in forum Java AppletsReplies: 6Last Post: 09-21-2008, 08:07 PM -
Applet
By kapoorje in forum Java AppletsReplies: 0Last Post: 07-24-2007, 04:06 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks