swing - How do I get an incremental display in java GUI program -


i have problem in moving java console gui program.

my console program loads words dictionary. uses each word in turn decrypt cipher, displaying deciphered text on screen first word, second word , on.

when write gui program, have command

jtextarea.append(decipherment); 

but nothing displayed until program has deciphered every word , decipherments displayed together, rather 1 one want.

the structure of gui program includes button code:

private void jbutton1actionperformed(java.awt.event.actionevent evt) {                                              decrypt(); } 

and there section:

public void decrypt(){     ... } 

that contains code load dictionary words, deciphering each word , display each decipherment method call: jtextarea.append(decipherment);

but, mentioned, individual decipherments not displayed. rather program runs end , displays decipherments together.

after reading other threads have feeling not writing gui program correctly haven’t found mistake is. appreciated.

your decrypting running in same thread gui , locking up. try spawning new thread run decryption, update gui in swing thread.

try this:

thread workthread = new thread(new runnable() {  // run process in new thread   public void run() {     decrypt();   } });  workthread.start(); 

how update swing thread:

eventqueue.invokelater(new runnable() {  // update swing thread here   public void run() {     jtextarea.append(decipherment);   } }); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -