The program can't complied as abstract class?

Dear all

Nice to meet you. I am Billy and come from Hong Kong. I would like to write a program as following:

import java.net.*;

import java.io.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

publicclass ListModHompageimplements ActionListener{

String meg =new String();

public ListModHompage(String name){

inputWebdataFile(name);

System.out.println(this.outputWebdataModified());

createGUIUpdateFile(name);

}

publicvoid inputWebdataFile(String name){

try{

FileInputStream in =new FileInputStream(name);

meg = name;

int i = 0;

while (in.available() != 0)

meg += (char) in.read();

in.close();

}

catch (Exception e){

System.out.println("Unexpected " + e);

}

}

public String outputWebdataModified(){

int i=meg.indexOf("Last Modified: ");//Find first space

String date=meg.substring(i+15, i+43);

return date;

}

publicstaticvoid main(String args[]){

new ListModHompage("webdata.txt");

}

publicvoid createGUIUpdateFile(String name){

try{

// FileOutputStream out = new FileOutputStream(name);

JFrame frame =new JFrame("");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel panel =new JPanel(new GridLayout(3, 1));

Button btnOK =new Button("OK");

Button exit =new Button("Exit");

JTextField field1 =new JTextField();

JTextField field2 =new JTextField();

JLabel label1 =new JLabel("What URL do you need to update?");

JLabel label2 =new JLabel("What date of URL do you modified?");

panel.add(label1);

panel.add(field1);

panel.add(label2);

panel.add(field2);

panel.add(btnOK);

panel.add(exit);

frame.getContentPane().add(panel);

frame.pack();

frame.setVisible(true);

frame.addWindowListener(new WindowAdapter(){

publicvoid windowClosing(WindowEvent e){

System.exit(0);

}

});

// out.close();

}catch (Exception e){

System.out.println(e);

}

}

}

The purpose of the program is that can fetch all of the web pages specified in the file, one by one, and

display the corresponding last modified date. And then, it can update the file about the last modified dates whenever necessary. After then, it can send email to the specified users about the change if there is any

update in the specified URLs.

When I complied the program, the complied time error would be occured by following:

ListModHompage.java:7: ListModHompage is not abstract and does not override abst

ract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.Action

Listener

public class ListModHompage implements ActionListener {

^

1 error

I know that what is abstract class but I don't understand why doesn't it complied. Would you mind tell me? Thanks for you help.

Billy

[5410 byte] By [BillyCheunga] at [2007-11-26 12:34:58]
# 1

The error message actually tells you: Your class implements ActionListener. ActionListener is an interface that requires each implementing class to provide at least the methods it defines. As your class is not defined abstract, it has to follow the interface of ActionListener. If your class would be defined abstract, it wouldn't need to implement that interface (but subclasses of your class would have to).

stefan.schulza at 2007-7-7 15:58:32 > top of Java-index,Java Essentials,Java Programming...
# 2
Hi,Yes, it doesn't compile because you have specified that the class implements ActionListener, and you must in that case implement the method:public void actionPerformed(java.awt.event.ActionEvent)Kaj
kajbja at 2007-7-7 15:58:32 > top of Java-index,Java Essentials,Java Programming...
# 3

Your class implements an interface. If you implement an interface your class must override all methods in that interface.

The ActionListener interface has the method:

public void actionPerformed(ActionEvent e)

You must implement this method in your class

Minkoa at 2007-7-7 15:58:32 > top of Java-index,Java Essentials,Java Programming...
# 4
Hello Billy,you write a class which implements ActionListener, but you haven't defined this listener's method (actionPerformed()) in your class.And this question should have been posted in the AWT or Swing forum.RegardsJ鰎g
Joerg22a at 2007-7-7 15:58:32 > top of Java-index,Java Essentials,Java Programming...
# 5
Hello.I am so sorry that I post wrong message in the forums. I understand now. Thanks.Billy
BillyCheunga at 2007-7-7 15:58:32 > top of Java-index,Java Essentials,Java Programming...