?? flyfont.java
字號:
import java.awt.*;
import java.applet.*;
public class FlyFont extends Applet implements Runnable{
private Image buffer;
private Graphics gContext;
private Font font;
private String string;
private Thread thread;
private int xpos, ypos, font_size;
public void init(){
String param;
buffer = createImage(getSize().width, getSize().height);
gContext = buffer.getGraphics();
param = getParameter("text");
if(param == null)
string = "You Can Input The String That You Want";
else string = param;
font = new Font("TimesRoman", Font.BOLD, 10);
}
public void start(){
if(thread == null){
thread = new Thread(this);
thread.start();
}
}
public void update(Graphics g){
paint(g);
}
public void paint(Graphics g){
gContext.setColor(Color.black);
gContext.fillRect(0,0,getSize().width, getSize().height);
font = new Font("TimesRoman", Font.BOLD, font_size);
gContext.setFont(font);
gContext.setColor(Color.yellow);
FontMetrics fm = gContext.getFontMetrics(font);
int font_height = fm.getHeight();
int w;
int base_line = getSize().height / 2 + font_height / 2;
w = fm.stringWidth(string);
w = (getSize().width - w) / 2;
gContext.drawString(string, w, base_line-=20);
g.drawImage(buffer,0,0, this);
font_size++;
}
public void run(){
while(true){
repaint();
if(font_size >getSize().height)
font_size = 0;
try{
Thread.sleep(50);
}catch (InterruptedException e){}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -