这是一段 在程序运行10秒后,调用windows的计算器的 程序代码那么该如何编写一段代码插入 能使 在屏幕上打印出 10秒的倒数数字 (例如 10 9 8 7 6 5 4 3 2 1 然后弹出windows计算器程序)import java.util.Timer;
import java.util.TimerTask;public class MyTimerTaskRun extends Timer{
public static void main(String[] args) {
class MyTimerTask extends TimerTask
{
private Timer tm=null;
public MyTimerTask(Timer tm)
{
this.tm=tm;
}
public void run()
{
try
{
Runtime.getRuntime().exec("calc.exe");
}
catch(Exception e)
{
e.printStackTrace();
}
tm.cancel();
}
}
Timer tm = new Timer();
tm.schedule(new MyTimerTask(tm), 10000);
}
}
import java.util.TimerTask;public class MyTimerTaskRun extends Timer{
public static void main(String[] args) {
class MyTimerTask extends TimerTask
{
private Timer tm=null;
public MyTimerTask(Timer tm)
{
this.tm=tm;
}
public void run()
{
try
{
Runtime.getRuntime().exec("calc.exe");
}
catch(Exception e)
{
e.printStackTrace();
}
tm.cancel();
}
}
Timer tm = new Timer();
tm.schedule(new MyTimerTask(tm), 10000);
}
}
import java.util.TimerTask; public class MyTimerTaskRun extends Timer{
public static void main(String[] args) { class MyTimerTask extends TimerTask
{ private Timer tm=null;
private int i;
public MyTimerTask(Timer tm,int i)
{
this.tm=tm;
this.i=i;
}
public void run()
{
System.out.println(i);
if(i==0)
try
{
System.out.println("执行!");//Runtime.getRuntime().exec("calc.exe");
}
catch(Exception e)
{
e.printStackTrace();
} tm.cancel();
} }
try {
for(int i=1;i<=10;i++){
Timer tm = new Timer();
MyTimerTask a=new MyTimerTask(tm,10-i);
tm.schedule(a, 1000);
Thread.sleep(1000);
}
}
catch (Exception e) {
}
}
}