求救啊..编译出错!!
我的是这样的啊!那里错啦.请各位看看!!import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class CanvasTest extends Canvas implements KeyListener
{
int index;
Color color[]={Color.red,Color.green,Color.blue};
public void paint(Graphics g)
{
g.setColor(color[index]);
g.fillRect(0,0,getSize().width,getSize().height);
}
public static void main(String[] args) {
Frame f=new Frame("Canavs");
CanvasTest mc=new CanvasTest();
f.add(mc,BorderLayout.CENTER);
f.setSize(200,200);
mc.requestFocus();
mc.addKeyListener(mc);
f.setVisible(true);
}
public void keyTyped(KeyEvent ev)
{
index++;
if (index==color.length)
{
index =0;
}
repaint();
}
public void keyReleased(KeyEvent ev){ }
public void keyPreeed(KeyEvent ev){ }
}
编译出错!!
Command : "C:\Program Files\Java\jdk1.6.0_03\bin\javac.exe" -classpath "C:\Program Files\Xinox Software\JCreatorV4\MyProjects\ChTest\CanvasTest\classes\;C:\Program Files\Java\jdk1.6.0_03\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_03\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_03\lib\tools.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.6.0_03\lib;C:\Program Files\Java\jdk1.6.0_03\bin;C:\Program Files\Java\jre1.6.0_03\lib" -d "C:\Program Files\Xinox Software\JCreatorV4\MyProjects\ChTest\CanvasTest\classes" @src_canvastest.txt
Directory : "C:\Program Files\Xinox Software\JCreatorV4\MyProjects\ChTest\CanvasTest"
C:\Program Files\Xinox Software\JCreatorV4\MyProjects\ChTest\CanvasTest\src\CanvasTest.java:12: CanvasTest 不是抽象的,并且未覆盖 java.awt.event.KeyListener 中的抽象方法 keyPressed(java.awt.event.KeyEvent)
public class CanvasTest extends Canvas implements KeyListener
^
1 错误
Process completed.