Displaying contents of String array in Swing component as iterations using Time delay. JAVA -


i have array of strings i'm trying display (one one) slideshow in java swing component. trying add delay time between iterations.

i attempted using jtextarea, action listener added it. here code have right now:

private class myactionlistener implements actionlistener {     public void actionperformed(actionevent e) {         // bunch of text processing          //note: myinfo.getcontents() returns arraylist<mytype>.         iterator<mytype> iterator = myinfo.getcontents().iterator();          int = 0;         while (iterator.hasnext()) {             mytextarea.settext(iterator.next().tostring());             // add time betweeen iterations wanted use thread             // delay method.         }     } } 

my code not working because jtextarea doesn't have action listener.

update note: many replies stated should use actionlistener jtextarea; however, eclipse not showing me jtextarea has method called addactionlistener.

i'm kind of stuck here, which java swing component think suitable in scenario?

the text in array may long, 1 lined label not choice.

what other alternatives or approaches have?

thank much, , suggestions appreciated.

use actionlistener in combination javax.swing.timer. actionlistener assigned timer called on regular intervals specified delay.

see the timer tutorial more information


Comments

Popular posts from this blog

python - How to create jsonb index using GIN on SQLAlchemy? -

PHP DOM loadHTML() method unusual warning -

c# - TransactionScope not rolling back although no complete() is called -