该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
尝试过使用事件分发线程,但还是空白,线程确实是运行着的。
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class test1 extends JPanel {
public void paint(Graphics g){
Thread t1=new Thread(new Runnable(){
public void run(){
g.fillRect(50, 50, 50, 50);
for(int i=0;;i++){
g.setColor(Color.BLACK);
g.fillRect(100+i*20,65,20,20);
try {
Thread.sleep(100); }
catch (InterruptedException e) {
e.printStackTrace(); }
g.setColor(Color.WHITE);
g.fillRect(100+i*20,65,20,20);
if((100+(i+1)*20)>=1500){
System.out.println("over1");
break; }
}}});
Thread t2=new Thread()