import java.awt.*;
import java.awt.event.*;
class ChessPad extends Panel implements MouseListener,ActionListener
{
int x=-1,y=-1,color=1;
Button button=new Button("Restart");
TextField text_1=new TextField("Please put down the black one"),
text_2=new TextField();
ChessPad()
{
setSize(440,440);
setLayout(null);setBackground(Color.orange);
addMouseListener(this);add(button);button.setBounds(10,5,60,26);
button.addActionListener(this);
add(text_1);text_1.setBounds(90,5,90,24);
add(text_2);text_2.setBounds(290,5,90,24);
text_1.setEditable(false);text_2.setEditable(false);
} //To draw the apperance of the chesspad.
public void paint(Graphics g)
{for(int i=40;i<=380;i=i+20)
{g.drawLine(40,i,400,i);
}
g.drawLine(40,400,400,400);
for(int j=40;j<=380;j=j+20)
{
g.drawLine(j,40,j,400);

}
g.drawLine(400,40,400,400);
g.fillOval(97,97,6,6);
g.fillOval(337,97,6,6);
g.fillOval(97,337,6,6);g.fillOval(337,337,6,6);
g.fillOval(217,217,6,6);
}
public void mousePressed(MouseEvent e) //When the mouse click the left button.
{
if(e.getModifiers()==InputEvent.BUTTON1_MASK)
{
x=(int)e.getX();y=(int)e.getY();
ChessPoint_black chesspoint_black=new ChessPoint_black(this);
ChessPoint_white chesspoint_white=new ChessPoint_white(this);
int a=(x+10)/20,b=(y+10)/20;
if(x/20<2||y/20<2||x/20>19||y/20>19)
{}
else
{
if(color==1)
{
this.add
在第三行中显示的是未覆盖ChessPad 不是抽象的,并且未覆盖java.awt.event.ActionListener中的什么,这是怎么回事啊
由于长度限制中间的一部分被我删了
程序时直接在书上打下来的
提问者:jezz
等级:资深程序员
发布时间:2010-03-17
悬赏:0
回答
你在开头class ChessPad extends Panel implements MouseListener,ActionListener
{

但是你的类中没有相应的实现ActionListener中的方法.所以会编译不过的.
实现ActionListener中的方法就可以了
回答者:jezz
等级:资深程序员
时间:2010-03-17
快到期问题
总积分排行
jezz 资深程序员reward 995
老三 中级程序员reward 65
三剑客 中级程序员reward 60
习羽 初级程序员reward 50
Fiona 初级程序员reward 45
java人 初级程序员reward 40
阿勇 初级程序员reward 35
扣921157070 初级程序员reward 35
155 初级程序员reward 35
haik 初级程序员reward 35