swing - How to avoid making EDT sleep when calling a method that has Thread.sleep -


so, i'm trying make jlabel's text text typing out. problem i'm not sure how make sure edt doesn't sleep , gui still updates here code.

startgametext() gets called somewhere else in program. (questions jlabel.)

    public void startgametext() throws interruptedexception {       swingutilities.invokelater(new runnable() {         public void run() {      w.questions.sethorizontalalignment(swingconstants.center);     w.questions.setfont(new font("helveltica", font.bold, 30));      typeoutquestions("....");       string awoken = "you have awoken in strange place. ";     typeoutquestions(awoken);       string remember = "you remember few things..";     typeoutquestions(remember);              } });        } 

this method want call update label questions.

public void typeoutquestions(string s) throws interruptedexception{      for(int = 0; <= s.length(); ++){          int p = 0;         w.questions.sethorizontalalignment(swingconstants.center);          w.questions.settext(s.substring(p, i));         p--;         thread.sleep(100);      }  } 

how make questions still updated through edt, edt not sleep?


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -