当前位置: 技术问答>java相关
一个java初级问题2
来源: 互联网 发布时间:2015-01-13
本文导语: 代码如下: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TimerTest implements ActionListener { int seconds=1; public void TimerTest() { Timer OneTimer=new Timer(10,this); Timer TwoTimer=new Timer(2000,new TimerWithDelayListen...
代码如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TimerTest implements ActionListener
{
int seconds=1;
public void TimerTest()
{
Timer OneTimer=new Timer(10,this);
Timer TwoTimer=new Timer(2000,new TimerWithDelayListener());
Timer ThreeTimer=new Timer(10000,new OneTimerListener());
TwoTimer.setInitialDelay(5000);
ThreeTimer.setRepeats(false);
OneTimer.start();
TwoTimer.start();
ThreeTimer.start();
Timer.setLogTimers(true);
}
public void actionPerformed(ActionEvent e)
{
if (seconds==0)
{
System.out.println("Time:"+seconds+"seconds");
}
else
{
System.out.println("Time:"+seconds+"seconds");
seconds++;
}
}
public static void main(String args[])
{
new TimerTest();
while (seconds
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TimerTest implements ActionListener
{
int seconds=1;
public void TimerTest()
{
Timer OneTimer=new Timer(10,this);
Timer TwoTimer=new Timer(2000,new TimerWithDelayListener());
Timer ThreeTimer=new Timer(10000,new OneTimerListener());
TwoTimer.setInitialDelay(5000);
ThreeTimer.setRepeats(false);
OneTimer.start();
TwoTimer.start();
ThreeTimer.start();
Timer.setLogTimers(true);
}
public void actionPerformed(ActionEvent e)
{
if (seconds==0)
{
System.out.println("Time:"+seconds+"seconds");
}
else
{
System.out.println("Time:"+seconds+"seconds");
seconds++;
}
}
public static void main(String args[])
{
new TimerTest();
while (seconds