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中的什么,这是怎么回事啊
由于长度限制中间的一部分被我删了
程序时直接在书上打下来的


995