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

📄 text3d.java

📁 java的几个小程序
💻 JAVA
字号:
import java.awt.*;
import java.applet.*;

public class Text3D extends Applet implements Runnable
{
  private Image myimage;
  private Image offI;
  private Graphics offG;
  private Thread mythread = null;
  private MediaTracker myimageTracker;
  
  private int height,width;
  private String text;
  private int fontSize;
  private Font font;
  
  public void init()
  {    
    width = this.size().width;
    height = this.size().height;
    this.setBackground(Color.gray);
    
    myimage = createImage(width,height);
    text = new String("Hello");
    String myString = new String(getParameter("Text"));
    if(myString != null)
      text = myString;
    fontSize = 30;
    font = new Font("TimesRoman",Font.BOLD,fontSize);
    
    myimageTracker = new MediaTracker(this);
    myimageTracker.addImage(myimage,0);
    
    try
    {
      myimageTracker.waitForID(0);
    }
    catch(InterruptedException e){}
    
    offI = createImage(width,height);
    offG = offI.getGraphics();
    
  }
  
  public void start()
  {
    if(mythread == null)
    {
      mythread = new Thread(this);
      mythread.start();
    }
  }
  
  public void run()
  {
    int x=15;
    int y = height-15;
    
    int R,G,B;
    
    offG.setFont(font);
    while(mythread != null)
    {
      
      R = (int)(255*Math.random());
      G = (int)(255*Math.random());
      B = (int)(255*Math.random());
     try
      {
        mythread.sleep(3000);
      }
      catch(InterruptedException ex){}
      offG.setColor(Color.blue);
      offG.fillRect(0,0,width,height);
      repaint();
 
      for(int i=0; i<10; i++)
      {
        offG.setColor(new Color((255-(255-R)*i/10),(255-(255-G)*i/10),(255-(255-G)*i/10)));
        offG.drawString(text,x-i,y-i);
        repaint();
        try
        {
          mythread.sleep(50);
        }
        catch(InterruptedException e){}
      }
      

    }
  }
  
  public void update(Graphics g)
  {
    paint(g);
  }
  
  public void paint(Graphics g)
  {
    g.drawImage(offI,0,0,this);
  }


}

⌨️ 快捷键说明

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