📄 donghuaword.java
字号:
import java.awt.*;
import java.applet.*;
public class donghuaword extends Applet implements Runnable{
Color nowcolor=Color.black;
public Thread runner;
public int xpos,tag=0;
public void init(){
xpos=600;
setBackground(Color.white);
}
public void start() {
if (runner == null); {
runner = new Thread(this); //new Thread
runner.start();
}
}
public void stop() {
if (runner != null) {
// runner.stop();
runner = null;
}
}
public void run() {
while(Thread.currentThread()==runner){
xpos=xpos-10;
if(xpos==10)
xpos=600;
repaint();
try { Thread.sleep(200); }
catch (InterruptedException e) { }
}
}
public void paint(Graphics g){
int red,green,blue;
red=(int)Math.floor(Math.random()*256);
green=(int)Math.floor(Math.random()*256);
blue=(int)Math.floor(Math.random()*256);
g.setColor(new Color(red,green,blue));
g.setFont(new Font("TimesRoman",Font.BOLD,48));
g.drawString("Hello!",xpos,60);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -