标题:利用多线程编程实现一个正在旋转的地球
取消只看楼主
云团
Rank: 2
等 级:论坛游民
帖 子:36
专家分:41
注 册:2017-1-9
结帖率:50%
 问题点数:0 回复次数:0 
利用多线程编程实现一个正在旋转的地球
程序代码:
package TestSY;

import java.awt.*;
import import import java.applet.*;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestRunnable extends Applet implements Runnable{
    Thread Thread;
    public Image image = null;
    public int t = 0;
    public void start(){
            Thread = new Thread(this);
            Thread.start();
    }
    public void run(){
        while(true){
            this.setSize(1000, 600);
            repaint();
            try{
                Thread.sleep(100);
            }catch(InterruptedException e){
                e.printStackTrace();
            }
        }
    }
    public void paint(Graphics g){
        try {
            image = ImageIO.read(new File("E:/zp/" + t + ".png"));
            t = (t + 1) % 110 ;
            g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
        } catch (IOException e) {
            e.printStackTrace();
        }    
    }
}
搜索更多相关主题的帖子: import java Image public Thread 
2019-01-11 15:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-492637-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012835 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved