小白求解为什么repaint()不能调用前面的paint()啊?
public void paint(Graphics g){
g.drawImage(bgImage, 0, 20, this);
g.setFont(new Font("黑体",Font.BOLD,20));
g.drawString("游戏信息:", 100, 60);
g.setFont(new Font("宋体",Font.BOLD,15));
g.drawString("黑方时间:", 60,480);
g.drawString("白方时间:", 250,480);
//绘制棋盘
for(int i=0;i<381;i++){
g.drawLine(13, 80+i, 394, 80+i);
g.drawLine(14+i, 81, 14+i,457 );
i+=20;
}
//标注点位
g.fillOval(74, 139, 5, 5);
g.fillOval(75, 394, 5, 5);
g.fillOval(328, 140, 5,5 );
g.fillOval(328, 393, 5, 5);
g.fillOval(202, 267, 5, 5);
//绘制棋子
for(int i=0;i<19;i++){
for(int j=0;j<19;j++){
if(allChess[i][j]==1){
int tempX=i*20+13;
int tempY=j*20+81;
g.fillOval(tempX-7, tempY-7, 14, 14);
}
if(allChess[i][j]==2){
int tempX=i*20+13;
int tempY=j*20+81;
g.setColor(Color.WHITE);
g.fillOval(tempX-7, tempY-7, 14, 14);
g.setColor(Color.BLACK);
g.drawOval(tempX-7, tempY-7, 14, 14);
}
}
}
}
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
//System.out.println("x:"+e.getX());
//System.out.println("y:"+e.getY());
x=e.getX();
y=e.getY();
if(x <=394 && x >= 13&& y >= 81&& y <= 457){
//JOptionPane.showMessageDialog(this, "已超出棋盘范围");
int i=(x-13)/20;
int j=(y-81)/20;
this.repaint();
}