?? spotlight.java
字號:
import java.awt.*;
import java.applet.*;
public class SpotLight extends Applet implements Runnable
{
private String text;
private Font font;
private Color c, spot;
private int font_size;
private Thread thread;
private int textpt = 50;
private int text_size = 20;
private int text_width = 0;
private int font_height,base_line,w;
public void init()
{
String fonts, temp;
text = getParameter("message");
if(text == null)
text = "You Can Input Some Message";
fonts = getParameter("font_size");
if(fonts == null)
font_size = 20;
else
font_size = Integer.parseInt(fonts);
font = new Font("TimesRoman", Font.BOLD, font_size);
FontMetrics fm = getFontMetrics(font);
font_height = fm.getHeight();
base_line = getSize().height / 2 + font_height / 3;
text_width = fm.stringWidth(text);
w = fm.stringWidth(text);
w = (getSize().width - w) / 2;
textpt = w;
c = new Color(255, 0, 0);
spot = new Color(255, 255, 255);
setBackground(Color.black);
}
public void start()
{
if(thread == null)
{
thread = new Thread(this);
thread.start();
}
}
public void stop()
{
thread.stop();
thread = null;
}
public void run()
{
while(true)
{
repaint();
try { Thread.sleep(50); }
catch(InterruptedException e) { }
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.setFont(font);
g.setColor(c);
g.drawString(text, w, base_line);
g.clipRect(textpt, 0, text_size, getSize().height);
g.setColor(spot);
g.drawString(text, w, base_line);
textpt = (textpt + 1) % (text_width + 100);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -