📄 lineshow.java
字号:
import java.applet.Applet;
import java.awt.*;
public class lineshow extends Applet implements Runnable {
int yStep = 0,
xPos = 0,
yPos = 0,
textWidth = 0;
Thread killme = null;
String inputText = null;
Font font = null;
Color bgColor = null,
txtColor = null;
public lineshow()
{
font = new Font("Helvetica", 2, 15);
bgColor = new Color(255, 255, 255);
txtColor = new Color(255, 0, 0);
yPos = 15;
yStep = 1;
}
public void init()
{
setBackground(bgColor);
inputText = getParameter("text");
if(inputText == null)
inputText = "Hello! World!";
FontMetrics fontmetrics = getFontMetrics(font);
textWidth = fontmetrics.stringWidth(inputText);
}
public void start()
{
if(killme == null)
{
killme = new Thread(this);
killme.start();
}
}
public void stop()
{
killme = null;
}
public void setcoord()
{
xPos = xPos + 2;
yPos = yPos + yStep;
if(xPos > 500)
xPos = -textWidth;
if(yPos > 45)
yStep = -1;
if(yPos < 15)
yStep = 1;
}
public void run()
{
while(killme != null)
{
try
{
Thread.sleep(100L);
}
catch(InterruptedException _ex) { }
setcoord();
repaint();
}
}
public void paint(Graphics g)
{
g.setColor(txtColor);
g.setFont(font);
g.drawString(inputText, xPos, yPos);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -