이 프로그램의 목적은 다른 사용자로부터 숫자를 얻은 다음 카운트 다운하는 것입니다.타이머 클래스에서 start() 메서드를 찾을 수 없습니다
프로그램을 아직 끝내지 않았습니다. 사용해야하는 방법이 없기 때문입니다.
타이머를 시작하려고하지만 start() 메소드를 찾을 수 없습니다. & 다른 방법.
다른 클래스를 가져와야합니까? -----> 타이머; 당신은 Timer 클래스를 사용하는 경우
package timerprojz;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Timer;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class TimeProjz extends JFrame {
JLabel promptLabel, timerLabel;
int counter;
JTextField tf;
JButton button;
Timer timer;
public TimeProjz() {
setLayout(new GridLayout(2, 2, 5, 5)); // 2 row 2 colum and spacing
promptLabel = new JLabel("Enter seconds", SwingConstants.CENTER);
add(promptLabel);
tf = new JTextField(5);
add(tf);
button = new JButton("start timeing");
add(button);
timerLabel = new JLabel("watting...", SwingConstants.CENTER);
add(timerLabel);
Event e = new Event();
button.addActionListener(e);
}
public class Event implements ActionListener {
public void actionPerformed(ActionEvent event) {
int count = (int) (Double.parseDouble(tf.getText()));
timerLabel.setText("T ime left:" + count);
TimeClass tc = new TimeClass(count);
timer = new Timer(1000, tc);
timer.start(); <-----------------can not find symbol
}
}
}