【Java开源代码栏目提醒】:网学会员为需要Java开源代码的朋友们搜集整理了Text3D.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);
}
}