帮忙看看这个五子棋的颜色怎么搞的?
Server
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import java.util.*;
class JPanels extends JPanel implements MouseListener
{
private PrintWriter out;
private int[][] map=new int[15][15];
public JPanels ()
{
for(int i=0;i <15;i++)
for(int j=0;j <15;j++)
map[i][j]=0;
this.addMouseListener(this);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
for(int i=0;i <15;i++)
{
g.drawLine(20,(i+1)*20,300,(i+1)*20);
g.drawLine((i+1)*20,20,(i+1)*20,300);
}
for(int m=0;m <15;m++)
for(int n=0;n <15;n++)
{
if(map[m][n]==1)
this.drawBlue(m*20,n*20,g);
else if(map[m][n]==-1)
this.drawRed(m*20,n*20,g);
}
}
public void setWriter(PrintWriter wr)
{
this.out=wr;
}
public void set(int x,int y,int z)
{
map[x][y]=z;
this.repaint();
}
public void drawBlue(int x,int y,Graphics g1)
{
g1.setColor(Color.blue);
g1.drawOval(x-5,y-5,10,10);
g1.fillOval(x-5,y-5,10,10);
}
public void drawRed(int x,int y,Graphics g1)
{
g1.setColor(Color.red);
g1.drawOval(x-5,y-5,10,10);
g1.fillOval(x-5,y-5,10,10);
}
public void mouseClicked(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
int x=(int)Math.round(e.getX()/(double)20);
int y=(int)Math.round(e.getY()/(double)20);
if(x> 0&&x <15&&y> 0&&y <15)
{
map[x][y]=-1;
out.println( "[STONE] "+x+ " "+y);
this.repaint();
}
else return;
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
}
public class Netserver extends JFrame implements Runnable
{
private JPanels p1=new JPanels();
private BufferedReader reader;
private PrintWriter writer;
private Socket socket;
private ServerSocket server;
public Netserver()
{
getContentPane().add(p1);
}
public void run()
{