私はここから見つけた小さな例を実行しようとしていますhttp://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html。しかし、私はType mismatch: cannot convert from void to Timer
をtimer = new Timer .....という行に付けます。私は誰かが私を助けることを望んでいた。タイマのコンパイルの問題
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//...Perform a task...
}
};
new Timer(delay, taskPerformer).start();
あなた
私のコードをありがとうございました。
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
public class MyTimerTest
{
private JFrame frame = new JFrame();
Container contentPane = frame.getContentPane();
Timer timer;
int delay = 1000; //a second
public MyTimerTest()
{
}
public void runTimer()
{
ActionListener taskPerformer = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0) {
}
};
timer = new Timer(delay, taskPerformer).start();
}
/**
* @param args
*/
public static void main(String[] args)
{
}
}
スイングます。これが失敗する原因はいくつでもありますが、より多くの状況が必要です。 –