Bonjour,
Un collegue a constate que l'affichage ne bougeait plus pendant
actionPerformed.
Voici un exemple.
//test2.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.* ;
import javax.swing.event.* ;
public class test2 extends JFrame{
JTextField t;
int max;
JButton b ;
public test2() {
super("test2");
getContentPane().setLayout(new FlowLayout());
t=new JTextField(10);
getContentPane().add(t);
t.setEditable(true);
b= new JButton("OK");
getContentPane().add(b);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
aff2() ;
}
});
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}) ;
pack() ;
setVisible(true);
for(int i=1;i<1000;i++) t.setText(""+i );
}
public static void main(String args[])
{
new test2();
}
public void aff2()
{
System.out.print("IN ");
max=max+1;
for(int i=1;i<10000+max;i++) {
t.setText((""+i)) ;
}
System.out.println(" OUT "+max);
}
}
Lorsque le programme demarre la valeur du JTextField est incrementee
-> 999.
En appuyant une premiere fois sur le bouton OK, on recommence le
processus -> 999+1.
L'incrementation s'effectue mais sans son affichage.
1000 apparait lorsque l'on sort de actionPerformed.
Pourriez-vous nous donner une solution pour afficher l'incrementation.
Merci d'avance.
Mathieu Clar