import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Teste extends JFrame implements ActionListener
{  
  JLabel l1, l2;
  JButton botao;
  
  public Teste()
  {  
    addWindowListener(new WindowAdapter()
                       {
                         public void windowClosing(WindowEvent e)
                         {
                           System.exit(0);
                         }
                       }
                     );
    setSize(300, 200);
    this.getContentPane().setLayout(new BorderLayout());
    botao = new JButton("Teste");
    this.getContentPane().add("North",botao);
    botao.addActionListener(this); 
    l1 = new JLabel("Desatualizado");
    this.getContentPane().add("Center", l1);
    l2 = new JLabel("deveria ser atualizada a hora aqui");
    this.getContentPane().add("South", l2);   
  }

  public void actionPerformed(ActionEvent evt)
  {  
    l1.setText("Atualizado pelo setText");
  }

  public void atualizaLabel() //deveria atualizar, mas naum estah funcionando
  {
    Date hoje = new Date();
    l2.setText(" " +(hoje.getHours()) + ":" + hoje.getMinutes() + ":" + hoje.getSeconds());
    l2.invalidate(); // isto naum estah funcionando     
    l2.validate();// isto tbem naum estah funcionando
    System.out.println(" " +(hoje.getHours()) + ":" + hoje.getMinutes() + ":" + hoje.getSeconds());
    //repaint();
  }
  public static void main(String[] args)
  {  
    Teste f = new Teste();
    f.show();       
    Thread t = new Thread(new Relogio()); 
    t.start();
  }
}

class Relogio extends Teste implements Runnable
{
  public void run()
  {
    while (true)
    {
      atualizaLabel();
      try 
      {
        Thread.sleep(1000);
      }
      catch (InterruptedException e){}
    }
  }
}

