Abstract?
When trying to compile a script that I copied out of a book that I am learning java in, I get this message and can't seem to fix it :(
Revolve.java:7: Revolve is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class Revolve extends JApplet
The script that I have written is below:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
publicclass Revolveextends JApplet
implements Runnable, ActionListener{
String[] pageTitle =new String[6];
URL[] pageLink =new URL[6];
Color butterscotch =new Color(255, 204, 158);
int current = 0;
Thread runner;
publicvoid init(){
pageTitle[0] ="Google";
pageLink[0] = getURL("http://google.com");
pageTitle[1] ="EasyWebbers";
pageLink[1] = getURL("http://easywebbers.com");
pageTitle[2] ="AdTxt";
pageLink[2] = getURL("http://adtxt.net");
pageTitle[3] ="JoshHendo";
pageLink[3] = getURL("http://joshhendo.com");
pageTitle[4] ="Webmasters Meet";
pageLink[4] = getURL("http://webmasters-meet.com");
pageTitle[5] ="NamePros";
pageLink[5] = getURL("http://namepros.com");
Button goButton =new Button("Go");
goButton.addActionListener(this);
FlowLayout flow =new FlowLayout();
setLayout(flow);
add(goButton);
}
URL getURL(String urlText){
URL pageURL =null;
try{
pageURL =new URL(getDocumentBase(), urlText);
}catch (MalformedURLException m){}
return pageURL;
}
publicvoid paing(Graphics screen){
Graphics2D screen2D = (Graphics2D) screen;
screen2D.setColor(butterscotch);
screen2D.fillRect(0, 0, getSize().width, getSize().height);
screen2D.setColor(Color.black);
screen2D.drawString(pageTitle[current], 5, 60);
screen2D.drawString("" + pageLink[current], 5, 80);
}
publicvoid start(){
if (runner ==null){
runner =new Thread(this);
runner.start();
}
}
publicvoid run(){
Thread thisThread = Thread.currentThread();
while (runner == thisThread){
current++;
if (current > 5){
current = 0;
}
repaint();
try{
Thread.sleep(10000);
}catch (InterruptedException e){
//do nothing
}
}
}
publicvoid stop(){
if (runner !=null){
runner =null;
}
}
publicvoid actionPreformed(ActionEvent evt){
if (runner !=null){
runner =null;
}
AppletContext browser = getAppletContext();
if (pageLink[current] !=null){
browser.showDocument(pageLink[current]);
}
}
}
When I copy and paste the same script off their website, it doesn't come up this error. This is the second time this has happend, and I can't see what is wrong with it (the only difference besids that I use tabs and the one on the site uses spaces, is the websites that are rotated :P). The script on the books site can be found here:
http://www.cadenhead.org/book/java-24-hours/source/chapter19/Revolve.java
Thanks :)

