Spécifier l'affichage d'une chaîne
Bonjour,
J'aimerais savoir comment afficher une chaîne de caractères (caractère par caractère), c'est-à-dire afficher un char dans un JTextField puis afficher l'autre après 2 seconds par exemple ?
Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String s = jTextField4.getText(), s1 = "";
String str = "";
int L = s.length();
int x = 1500;
for (int i=0; i< L; i++)
{
char prem = s.charAt(i);
str= str + prem;
x = x + 2000;
final Thread th4 = new Thread (new Runnable() {
public void run() {
try {
Thread.sleep(x);
} catch (InterruptedException ex) {
}
}
});
th4.start();
//jLabel32.setForeground(Color.BLUE);
s1 = s1.concat(str);
jTextField3.setText(s1);
}
} |
Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?
Merci d'avance pour votre aide.