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

📄 splash.java

📁 这是一个splash的例子
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;

public class splash extends Applet
    implements Runnable
{
    int XMAX = 112;
    float[] m_Height = new float[XMAX] ;    //current height
    float[] m_G = new float[XMAX] ;         //move value before
    float b = 1.01f ;       //load factor
    float fWeight = 3 ;     //wave speed
    private Thread m_NAMI2D=null;
    
    public boolean mouseDown(Event event, int i, int j)
    {
        m_Height[i / 4 - 1] += j / 2;
        m_Height[i / 4] += j;
        m_Height[i / 4 + 1] += j / 2;
        return false;
    }

    public void paint(Graphics g)
    {
        g.setColor(Color.red);
        float f1 = 3F * fWeight;
        float f2 = f1 - 2.0F;
        m_Height[0] = m_Height[1];
        m_Height[XMAX - 1] = m_Height[XMAX - 2];
        float f = m_Height[0];
        for(int i = 1; i < XMAX - 1; i++)
        {
            float f3 = ((f + f2 * m_Height[i] + m_Height[i + 1]) / f1 + m_G[i]) / b;
            f = m_Height[i];
            m_G[i] = f3 - f;
            m_Height[i] = f3;
            g.clearRect((i - 1) * 4, (int)f3 - 30, 4, 60);
            g.fillRect((i - 1) * 4, (int)f3 + 30, 4, 60);
        }

    }

    public void run()
    {
        do
            try
            {
                repaint();
                Thread.sleep(50L);
            }
            catch(InterruptedException _ex)
            {
                stop();
            }
        while(true);
    }

    public void start()
    {
        if(m_NAMI2D == null)
        {
            m_NAMI2D = new Thread(this);
            m_NAMI2D.start();
        }
    }

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

    public void update(Graphics g)
    {
        paint(g);
    }
}

⌨️ 快捷键说明

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