?? mythread.java
字號(hào):
import java.applet.Applet;
import java.awt.*;
public class myThread extends Canvas implements Runnable{
int myPosition=0;
String myName;
int numberofSteps=500;
public myThread(String inName){
myName=new String(inName);
}
public synchronized void paint(Graphics g){
g.setColor(Color.black);
g.drawLine(0,size().height/2,size().width,size().height/2);
g.setColor(Color.red);
g.fillOval((myPosition*size().width/numberofSteps),0,10,size().height);
}
public void run(){
while(myPosition<numberofSteps){
myPosition++;
repaint();
try{
Thread.currentThread().sleep(5);
}catch(Exception e){
System.out.println("Exception on sleep");
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -