java - JButton Display text in JLabel -


i develop game

in first button, write word. in second button , enter letter

i find word register first button. problem can not previous research do.

i not understand how do, maybe me, great! sorry approximativ

example :

if write word first jbutton : "hello" program return _ _ _

if search "h", second button program return : h _ _ _ _ // in labelword

but now, if search "e" program return e _ _ _, "h" not repost.

my code, first jbutton :

controllerpendu = new controllerpendu(); final jframe popup = new jframe(); this.word = joptionpane.showinputdialog(popup, "enter 1 word", null);  //control lenght of word, if word < = 3  string afterctrl = a.controlew(word);   labelword.settext(""); (int = 0; < afterctrl.length(); i++) {     labelword.settext(labelword.gettext() + "_ ");     labelword.validate();     labelcompteur.repaint(); }  //counter key on word, panel top/right string mot = this.word; labelcompteur.settext(string.valueof(mot.length())); 

and 2nd jbutton :

controllerpendu = new controllerpendu();  final jframe popup = new jframe(); this.key = joptionpane.showinputdialog(popup, "enter 1 key", null);  char ctrlkey = a.controlek(key).charat(0);      // loop print key of word (int = 0; < this.word.length(); i++) {      //retourn key in function index      char lettre = word.charat(i);       if (ctrlkey == lettre) {         labelword.settext(key);      } else  {         labelword.settext(labelword.gettext() + "_ ");      } }      } else  {         //is ke isn't match, display "_ "          labelword.settext(labelword.gettext() + "_ ");      } } 

controllerpendu class check word , letter ctrlkey = key tiped in second jbutton

why don't store search result in instance variable string searchresult, can update each time new search has place.

sorry, wish post in how that, code missing parts , can't make wild guess on top of have forwarded.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -