import java.awt.*;
import javax.swing.*;

public class Prog1 {

  public static void main(String[] args) {
    JFrame frame=new JFrame();
    final JButton button=new JButton("toto");
    button.setBackground(Color.black);
    frame.getContentPane().add(button);

    new Thread() {
      public void run() {
        for(;;) {
          try {
            Thread.sleep(1000);
          } catch(InterruptedException e) {
          }

          button.setBackground(
            (button.getBackground()==Color.black)?
              Color.red:Color.black);
          }
        }
      }.start();

      frame.setSize(400,300);
      frame.setVisible(true);
    }
  }