Ayuda con Timers
Publicado por Itzel (6 intervenciones) el 19/09/2007 00:28:49
Hola, tengo un problema, tengo este codigo, el cual son dos botones, uno de send y otro close.
cuando le doy el send se crea inicia el timer lo cual esta bien, pero no logro parar el timer, no le hace caso al stop, me podrian decir ke tengo mal o como le puedo hacer para que haga stop y deje de transmitir
public void actionPerformed(ActionEvent e){
Object fuente = e.getSource();
ActionListener actionListener=new ActionListener(){
public void actionPerformed(ActionEvent e){
String LN=Char_to_String.Convertions(0x14)+ft.Return_Color_Line1();
String getTextLines="";
for(int i=0; i<tno_tf; i++){
getTextLines+=LN+usrTf[i].getText()+CR; //System.out.println(usrLabel[i].getText()+" "+usrTf[i].getText()+CR);
}
cadEnvio=SOM+"2"+get_CaptionVision()+CR+getTextLines+EOM+CR;
ps=new SendSerial(cadEnvio);
ps.Method_SendSerial(sp);
}
};
timer=new Timer(1000, actionListener);
else if(fuente == Button_Send){
timer.start();
}
else if(fuente == Button_Close){
timer.stop();
}
cuando le doy el send se crea inicia el timer lo cual esta bien, pero no logro parar el timer, no le hace caso al stop, me podrian decir ke tengo mal o como le puedo hacer para que haga stop y deje de transmitir
public void actionPerformed(ActionEvent e){
Object fuente = e.getSource();
ActionListener actionListener=new ActionListener(){
public void actionPerformed(ActionEvent e){
String LN=Char_to_String.Convertions(0x14)+ft.Return_Color_Line1();
String getTextLines="";
for(int i=0; i<tno_tf; i++){
getTextLines+=LN+usrTf[i].getText()+CR; //System.out.println(usrLabel[i].getText()+" "+usrTf[i].getText()+CR);
}
cadEnvio=SOM+"2"+get_CaptionVision()+CR+getTextLines+EOM+CR;
ps=new SendSerial(cadEnvio);
ps.Method_SendSerial(sp);
}
};
timer=new Timer(1000, actionListener);
else if(fuente == Button_Send){
timer.start();
}
else if(fuente == Button_Close){
timer.stop();
}
Valora esta pregunta


0