如何能在java重实现时间监视,定时运行 个人觉得不大可能!因为要调用操作系统底层的控制!用JNI调用WIN的API也许可以,不过没试过! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用Timer.详见http://www.csdn.net/Expert/topic/498/498599.shtm import javax.swing.Timer.*;ActionListener myAL;Timer MyTimer;int internal=1000; //你要的时间间隔myAL=new ActionListener(){ public void actionPerformed(ActionEvent e){ 此处为你要运行的程序 } };MyTimer=new Timer(internal,myAL);MyTimer.start(); import java.awt.*;import javax.swing.*;import java.awt.event.*;import javax.swing.Timer.*;public class Test extends JPanel{ ActionListener myAL; Timer MyTimer; int internal=1000; //你要的时间间隔 int myout=0; int m=1; int d=0; Container panel=this; JPanel panel1=new JPanel(new BorderLayout()); JLabel label=new JLabel(); public Test(){ add(panel1); panel1.add(label); myAL=new ActionListener(){ public void actionPerformed(ActionEvent e){ MyTimer.stop(); if(myout<50)run(); } }; MyTimer=new Timer(internal,myAL); run(); } void run(){ myout+=2; label.setText(String.valueOf(myout)); MyTimer.start(); } public static void main(String args[]){ JFrame f=new JFrame("MYTEST"); Test mytest=new Test(); f.getContentPane().add(mytest); f.setSize(300,300); f.show(); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);} }); }} 如何实现字符串的匹配 java反射求助 线程start倒底是由什么决定? 关于二维数组的问题 在线等. 怎样包含一个同文件夹下的类? 求教:String与StringBuffer的区别。 java中如何显式Free一个对象? EJB3.0 可以和Spring+hibernate 哪个牛 JFrame窗口如何最大化 如何使用java做套打?最好有例子,急!在线等待 SCJP的请看过来!!!此题的正确答案为???? 紧急求助!!!哪里有Weblogic的使用手册或相关学习资料???
详见http://www.csdn.net/Expert/topic/498/498599.shtm
Timer MyTimer;
int internal=1000; //你要的时间间隔myAL=new ActionListener(){
public void actionPerformed(ActionEvent e){
此处为你要运行的程序
}
};
MyTimer=new Timer(internal,myAL);MyTimer.start();
import javax.swing.*;
import java.awt.event.*;
import javax.swing.Timer.*;
public class Test extends JPanel{
ActionListener myAL;
Timer MyTimer;
int internal=1000; //你要的时间间隔
int myout=0;
int m=1;
int d=0;
Container panel=this;
JPanel panel1=new JPanel(new BorderLayout());
JLabel label=new JLabel(); public Test(){
add(panel1);
panel1.add(label);
myAL=new ActionListener(){
public void actionPerformed(ActionEvent e){
MyTimer.stop();
if(myout<50)run();
}
};
MyTimer=new Timer(internal,myAL);
run();
} void run(){
myout+=2;
label.setText(String.valueOf(myout));
MyTimer.start();
} public static void main(String args[]){
JFrame f=new JFrame("MYTEST");
Test mytest=new Test();
f.getContentPane().add(mytest);
f.setSize(300,300);
f.show();
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}
});
}
}