⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.java

📁 矩阵乘法的计算程序
💻 JAVA
字号:
import java.awt.*;
import java.util.Date;
import java.applet.Applet;
/*此程序能改为extends Apple,Thread吗?
 */
public class Class1 extends Applet implements Runnable
{
	Thread clockThread;
	String nowDate;
	getdateThread gt;
	public void init(){
		gt=new getdateThread("getdate");
		nowDate=gt.datestr;
		gt.start();
	}
	public void start(){
		if (clockThread==null){
			clockThread=new Thread(this,"Clock");
			clockThread.start();
		}
	}
	public void run(){
		while(clockThread !=null){
			repaint();
			try{
				clockThread.sleep(1000);
			}catch(InterruptedException e){}
		}
	}
	public void paint(Graphics g){
		g.drawString(nowDate,5,10);
	}
	public void stop(){
		clockThread.stop();
		gt.stop();
		clockThread=null;
	}
	
}

class getdateThread extends Thread{
	String datestr;
	public getdateThread(String str){
		super(str);
	}
	public void run(){
		while(true){
			Date now=new Date();
			datestr="time="+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
			try{
				this.sleep(1000);
			}catch(InterruptedException e){}
		}
	}
}
		
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -