watch.java

来自「在IE中查看系统时间」· Java 代码 · 共 29 行

JAVA
29
字号
import java.awt.*;
import java.util.*;
import javax.swing.JApplet;
public class Watch extends 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 time = day.getTime().toString();
        screen2D.setColor(Color.black);
        screen2D.drawString(lastTime, 5, 25);
        screen2D.setColor(butterscotch);
        screen2D.drawString(time, 5, 25);
        try{
            Thread.sleep(1000);
        }catch(InterruptedException e){
            //do nothing
        }
        lastTime = time;
        repaint();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?