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

📄 appletshow.java~9~

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

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

public class AppletShow extends Applet implements Runnable{
    boolean isStandalone = false;
    BorderLayout borderLayout1 = new BorderLayout();
    private String[] ss={"ACCP3.0","BNET1.0","JUNIOR1.0","BTEST1.0"};
    private Color[] colors={Color.red,Color.blue,Color.black,Color.ORANGE};
    int current=0;
    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 AppletShow() {
    }

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

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

    }

    //Start the applet
    public void start() {
        thread.start();
    }
    public void paint(Graphics g){
        g.clearRect(0,0,400,300);
        g.setFont(new Font("宋体",1,30));
        g.setColor(colors[current]);
        g.drawString(ss[current],180,140);
    }
    //Stop the applet
    public void stop() {
        try{
            thread.join();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    //Destroy the applet
    public void destroy() {
    }

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

    //Get parameter info
    public String[][] getParameterInfo() {
        return null;
    }
    public void run(){
        do{
            try{
                Thread.sleep(1000);
            }catch(Exception e){
                e.printStackTrace();
            }
            current++;
            if(current>3) current=0;
            repaint();
        }while(true);
    }
}

⌨️ 快捷键说明

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