import java.awt.*;
import java.util.*;public class Clock extends javax.swing.JApplet{
 private Color butterscotch=new Color(255,204,102);
 private String lastTime="";
 
 public void init(){
  setBackground(Color.black);
  }
 
 public void paint(Graphics screen){
   Graphics2D screen2D=(Graphics2D)screen;
   Font type=new Font("Monospaced",Font.BOLD,20);
   screen2D.setFont(type);
   GregorianCalendar day=new GregorianCalendar();
   String nowTime=day.getTime().toString();
   screen2D.setColor(Color.black);
   screen2D.drawString(lastTime,5,25);
   screen2D.setColor(butterscotch);
   screen2D.drawString(nowTime,5,25);
   try{
      Thread.sleep(1000);
    }
   catch(InterruptedException e){
   
    }
   lastTime=nowTime;
   repaint();
  }
}

解决方案 »

  1.   

    不知道是不是这个意思
    import java.awt.*;
    import java.util.*;public class Clock extends javax.swing.JApplet{
    private Color butterscotch=new Color(111,111,111);
    private String lastTime=""; public void init(){
    setBackground(Color.BLACK);
    }

    public void changeColor(Color color){
    setBackground(color);
    } public void paint(Graphics screen){
    Graphics2D screen2D=(Graphics2D)screen;
    Font type=new Font("Monospaced",Font.BOLD,10);
    screen2D.setFont(type);
    GregorianCalendar day=new GregorianCalendar();
    String nowTime=day.getTime().toString();
    screen2D.drawString(lastTime,5,25);
    screen2D.setColor(butterscotch);
    screen2D.drawString(nowTime,5,25);
    try{
    Thread.sleep(1000);
    }
    catch(InterruptedException e){ }
    this.changeColor(Color.blue);
    this.setVisible(false);
    this.setVisible(true);
    lastTime=nowTime;
    repaint();
    }
    }
      

  2.   

    还是这样?
    import java.awt.*;
    import java.util.*;public class Clock extends javax.swing.JApplet{
    private Color butterscotch=new Color(0,255,0);
    private String lastTime=""; public void init(){
    setBackground(Color.BLACK);
    }

    public void changeColor(Color color){
    setBackground(color);
    } public void paint(Graphics screen){
    Graphics2D screen2D=(Graphics2D)screen;
    Font type=new Font("Monospaced",Font.BOLD,20);
    screen2D.setFont(type);
    GregorianCalendar day=new GregorianCalendar();
    String nowTime=day.getTime().toString();
    screen2D.clearRect(0, 0, 10000, 10000);
    screen2D.setColor(butterscotch);
    screen2D.drawString(lastTime,5,25);

    screen2D.setColor(Color.WHITE);
    screen2D.drawString(nowTime,5,50);
    try{
    Thread.sleep(1000);
    }
    catch(InterruptedException e){ }
    /*//this.changeColor(Color.blue);
    System.out.println(screen2D.getBackground());
    this.setVisible(false);
    this.setVisible(true);*/
    lastTime=nowTime;
    repaint();
    }
    }
      

  3.   

    问题解决了 
    谢谢楼上的wuhaozhiyuan(飘)