⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 falconapplet.java~4~

📁 java基础,用JCreator Pro写一个界面更换的小程序,是北大清鸟s2的试题哦
💻 JAVA~4~
字号:
package TestApplet;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.Date;

/******************************
 显示当前时间,每秒钟对显示作一次刷新
*******************************/

public class FalconApplet extends Applet implements Runnable{
    boolean isStandalone = false;
    BorderLayout borderLayout1 = new BorderLayout();

    Thread thread;

    //Get a parameter value
    public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
                (getParameter(key) != null ? getParameter(key) : def);
    }

    //Construct the applet
    public FalconApplet() {
    }

    //Initialize the applet
    public void init() {
        try {
            if(thread==null){
                thread=new Thread(this,"clock");
                thread.start();
            }
            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //Component initialization
    private void jbInit() throws Exception {
    }

    //Get Applet information
    public String getAppletInfo() {
        return "Applet Information";
    }

    //Get parameter info
    public String[][] getParameterInfo() {
        return null;
    }

    public void run(){
        while(Thread.currentThread()==thread){
            repaint();
            try{
                thread.sleep(1000);
            }catch(Exception e){
                e.printStackTrace();
            }
       }
    }

    public void paint(Graphics g){
        int h,m,s;
        Date now=new Date();
        h=now.getHours();
        m=now.getMinutes();
        s=now.getSeconds();
        g.drawString(h+":"+m+":"+s,5,10);
    }
    public void stop(){
        thread.stop();
    }
}

⌨️ 快捷键说明

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