I am having a problem get my program to compile.
ERROR
Stopwatch.java:35: cannot find symbol
symbol : method start()
location: class Timer
timer.start();
^
Stopwatch.java:44: cannot find symbol
symbol : method stop()
location: class Timer
timer.stop();
^
Stopwatch.java:52: cannot find symbol
symbol : constructor Timer(int,Stopwatch)
location: class Timer
timer = new Timer(1000, this);
^
3 errors
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Stopwatch extends JApplet implements ActionListener
{
//instance variables
private JLabel countLabel;
private JButton start;
private JButton stop;
private Timer timer;
private int count= 0;
public void init()
{
//set layout
setLayout(new BorderLayout());
countLabel = new JLabel("");
countLabel.setHorizontalAlignment(JLabel.CENTER);
countLabel.setForeground(Color.RED);
countLabel.setFont(new Font("Times new Roman", Font.BOLD, 60));
add(countLabel, BorderLayout.CENTER);
JPanel panel = new JPanel();
start = new JButton ("Start");
start.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
count = 1;
timer.start();
}
});
stop = new JButton ("Stop");
stop.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
timer.stop();
}
});
panel.add(start);
panel.add(stop);
add(panel, BorderLayout.NORTH);
//getting the new timer
timer = new Timer(1000, this);
} // end method init
//
public void paint(Graphics g) {
countLabel.setText(""+ count);
count++;
}
//method for handling the actions
public void actionPerformed(ActionEvent e) {
repaint();
}
} // end class