为什么不能将棋子添加到棋盘
public void paint(Graphics g){
super.paint(g);
f2 =(Graphics2D)g;
for (int i = 50;i<330;i=i+30){
f2.drawLine(i, 50, i, 320);
f2.drawLine(50, i, 320, i);
}
this.addMouseListener(new AL());//添加鼠标事件
if( c==true){
f2.drawOval(x, y, 10, 10);//在x,y坐标下画圆
}
}
public class AL extends MouseAdapter{
public void MousePressed(MouseEvent e){
c=true;
if(50<e.getX()&&e.getX()<320){
x=e.getX();//得到x坐标
}
if(50<e.getY()&&e.getY()<320){
y=e.getY();//y坐标
}