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

📄 nationday.java

📁 用JAVA小应用制作庆祝建国50周年的广告牌
💻 JAVA
字号:
// Decompiled Using: FrontEnd Plus v2.03 and the JAD Engine
// Available From: http://www.reflections.ath.cx
// Decompiler options: packimports(3) 
// Source File Name:   NationDay.java

import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;

public class NationDay extends Applet
    implements Runnable
{

    public void init()
    {
        if(!init)
        {
            init = true;
            tracker = new MediaTracker(this);
            allImages = new Image[7];
            for(int i = 0; i < 7; i++)
                allImages[i] = getImage(getCodeBase(), "Mrab0" + i + ".gif");

            for(int j = 0; j < 7; j++)
                tracker.addImage(allImages[j], j);

            backImage = getImage(getCodeBase(), "50.gif");
        }
    }

    public void paint(Graphics g)
    {
        setBackground(Color.white);
        if(bz_load)
        {
            bz_anima = true;
            g.drawImage(backImage, 0, 0, this);
            g.drawImage(allImages[current], frame_x, 0, this);
            return;
        } else
        {
            g.drawString("\u753B\u9762\u8F7D\u5165\u4E2D, \u8BF7\u7A0D\u4FAF......", 0, 20);
            return;
        }
    }

    public void start()
    {
        String s = "spacemusic.au";
        m_Audio = getAudioClip(getDocumentBase(), s);
        if(m_Audio != null)
            m_Audio.loop();
        if(animation == null)
        {
            animation = new Thread(this);
            animation.start();
        }
    }

    public void stop()
    {
        if(m_Audio != null)
            m_Audio.stop();
        if(animation != null)
        {
            animation.stop();
            animation = null;
        }
    }

    public void run()
    {
        for(; !checkRoll(); sleep(100));
        bz_load = true;
        do
            roll(0, getSize().width - 42);
        while(true);
    }

    boolean checkRoll()
    {
        boolean flag = true;
        for(int i = 0; i < 7; i++)
            if((tracker.statusID(i, true) & 8) == 0)
                flag = false;

        return flag;
    }

    void roll(int i, int j)
    {
        if(i < j)
        {
            for(int k = i; k <= j; k += 21)
            {
                frame_x = k;
                repaint();
                current--;
                if(current == -1)
                    current = 3;
                sleep(150);
            }

            return;
        }
        for(int l = i; l >= j; l -= 21)
        {
            frame_x = l;
            repaint();
            current++;
            if(current == 7)
                current = 0;
            sleep(150);
        }

    }

    private void sleep(int i)
    {
        try
        {
            Thread.sleep(i);
            return;
        }
        catch(InterruptedException _ex)
        {
            return;
        }
    }

    public void update(Graphics g)
    {
        g.clipRect(0, 0, 2000, 2000);
        paint(g);
    }

    public NationDay()
    {
        bz_load = false;
        bz_anima = false;
        init = false;
    }

    MediaTracker tracker;
    int frame_x;
    boolean bz_load;
    boolean bz_anima;
    int current;
    private boolean init;
    private AudioClip m_Audio;
    Image backImage;
    Image myImage;
    Image allImages[];
    Thread animation;
}

⌨️ 快捷键说明

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