How to change value of Java swing JTextArea dynamically

30 views Asked by At
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    for(int i=0;i<10;i++){
        try {
            Thread.sleep(2000);
            jTextArea1.setText(String.valueOf(i));
        } catch (InterruptedException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
private javax.swing.JTextArea jTextArea1;

After every 2 seconds I need to change the value of jTextArea1. But it shows only the final value which is '9'.

0

There are 0 answers