我在YouTube上觀看教程,在這裏我到目前爲止的代碼,構造定時器(INT,ClockC.Listener)是未定義
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.management.timer.Timer;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class ClockC extends JFrame{
private static final long serialVersionUID = 1L;
JTextField time;
JPanel p1;
public ClockC() {
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setResizable(true);
setLocationRelativeTo(null);
p1 = new JPanel();
p1.setLayout(new FlowLayout());
time = new JTextField(10);
time.setEditable(false);
time.setFont(new Font("Arial", Font.PLAIN, 48));
p1.add(time);
add(p1);
Timer t = new Timer(1000, new Listener);
t.start();
}
class Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
}
}
}
問題是,當我到了定時器T =新定時器(1000,新聽衆);我得到一個錯誤,說它的身份不明。
謝謝。
什麼語言是什麼? –