?? text3d.java
字號(hào):
import java.awt.*;
import java.applet.*;
public class Text3D extends Applet implements Runnable
{
private Image img;
private Image offI;
private Graphics offG;
private Thread thread = null;
private MediaTracker imageTracker;
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.black);
img = createImage(width,height);
Graphics temp = img.getGraphics();
temp.setColor(Color.black);
temp.fillRect(0,0,width,height);
temp.setColor(Color.red);
text = new String("Hello");
String s = new String(getParameter("Text"));
if(s != null)
text = s;
FontSize = 30;
font = new Font("TimesRoman",Font.BOLD,FontSize);
temp.setFont(font);
temp.drawString(text,10,height*3/4);
imageTracker = new MediaTracker(this);
imageTracker.addImage(img,0);
try
{
imageTracker.waitForID(0);
}
catch(InterruptedException e){}
offI = createImage(width,height);
offG = offI.getGraphics();
}
public void start()
{
if(thread == null)
{
thread = new Thread(this);
thread.start();
}
}
public void run()
{
int x=15;
int y = height-15;
int R,G,B;
offG.setFont(font);
while(thread != null)
{
R = (int)(255*Math.random());
G = (int)(255*Math.random());
B = (int)(255*Math.random());
try
{
thread.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
{
thread.sleep(50);
}
catch(InterruptedException e){}
}
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(offI,0,0,this);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -