Action Listeners
Hi again.
I am trying to make a class that implements an Action Listener interface.
publicclass CalendarFrameimplements ActionListener{
is how my class starts. However, it comes out with a really weird error message : datefinder.CalendarFrame is not abstract and does not override abstract method ActionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener . How can I take care of that?
Thanks.
[571 byte] By [
ApRiXa] at [2007-11-27 6:17:38]

Check this code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AL extends JFrame implements ActionListener {
JTextField text = new JTextField(20);
JButton b;
private int numClicks = 0;
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
AL myWindow = new AL("My first window");
myWindow.setSize(350,100);
myWindow.setVisible(true);
}
});
}
public AL(String title) {
super(title);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b = new JButton("Click me");
add(b);
add(text);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
numClicks++;
text.setText("Button Clicked " + numClicks + " times");
}
}
when you are implementing an interface, you should write codes for fuctions that the interface specifies, it is mandatory..refer documents for interfaces and their functions... if you are not bothered about all functions in an interface use adapter classes...
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/package-summary.html
faheda at 2007-7-12 17:30:47 >
