INTERROMPER o looping da Thread

0 respostas
DANIEL35
Olá amigos, estou tentando interromper o loopind dessa thread, pois a cada 3 segundos aparece uma nova tela para logar, e não para nunca. O ideal é que apareça a tela de introdução e suma depois de 3 segundos, e aí sim, venha a tela para logar, e pronto. Mas acontece que a cada 3 segundos surge uma tela nova.... Alguém de boa vontade poderia me ajudar a resolver essa situação? Obrigado. Vejam o código:
import java.awt.*;  
import javax.swing.*;  
import java.awt.event.*;  
import java.util.TimerTask; ;     
import java.util.Timer;     
  
class TelaIntroducao extends JFrame {  
    public static final long TEMPO = (3000);   
    FontMetrics fm;  
    String s = "Testessss...";  
      
   public TelaIntroducao() {      
    setTitle("TESTE");  
  
    getContentPane().setLayout(new FlowLayout());   
      
     Timer timer = null;        
         if (timer == null) {        
             timer = new Timer();      
                         
             TimerTask tarefa = new TimerTask() {     
  
                 public void run() {   
                         
                     try {  
                            new TelaLogar();     
                            dispose();  
                      }catch (Exception e){  
                        e.printStackTrace();       
                            
                     }   
                                  
                 }   
                     
             };  
                       
             timer.scheduleAtFixedRate(tarefa, TEMPO,TEMPO);  
        }  
          
    Font font = new Font("Jokerman", Font.ITALIC, 36);  
    setFont(font);  
    fm = getFontMetrics(font);  
    setSize(fm.stringWidth(s)+30, fm.getHeight()+60);  
          
    setVisible(true);  
    setSize(550, 550);  
    setResizable(false);  
    setLocationRelativeTo(null);      
  
   }  
     
   public void paint(Graphics g) {  
          
      Insets ins = getInsets();  
      int w = getSize().width-ins.left-ins.right;  
      int h = getSize().height-ins.top-ins.bottom;  
  
      int centerX = w/2 + ins.left;  
      int centerY = h/2 + ins.top;  
  
      g.setColor(Color.red);  
      g.fillRect(ins.left, ins.top, w, h);  
  
      g.setColor(Color.yellow);  
      g.drawString(  
         s,   
         centerX-fm.stringWidth(s)/2,   
         centerY + (fm.getAscent()-fm.getDescent())/2  
      );  
              
   }  
}
Criado 12 de junho de 2010
Respostas 0
Participantes 1