编的是个五子棋,现在只做好界面,运行程序,窗体上的按钮文本框没有显示,只有把鼠标放到上面才能正常显示,求指教
代码package org.szx.fivechess;import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;import javax.imageio.ImageIO;
import javax.swing.*;public class ChessPanel extends JFrame {
// private JFrame chessJFrame =  new JFrame("网络五子棋游戏") ;
//鼠标点击的X坐标
private int x; 
//鼠标点击的Y坐标
private int y;
        //登录界面对象
public LoginPanel lp; 
// 悔棋命令
final static int OPRATION_REPENT = 0xEF; 
// 接受悔棋命令
final static int OPRATION_NODE_REPENT = 0xCF; 
// 和棋命令
final static int OPRATION_DRAW = 0xFE; 
// 接受和棋命令
final static int OPRATION_NODE_DRAW = 0xEE; 
// 开始命令
final static int OPRATION_START = 0xFd; 
// 接受开始命令
final static int OPRATION_ALL_START = 0xEd; 
// 认输命令
final static int OPRATION_GIVEUP = 0xFc; 
// 胜利代码
final static int WIN = 88; 
private JLabel ipJLabel = new JLabel();
private JLabel nameJLabel = new JLabel();
private JTextField nameJTextField = new JTextField();
private BufferedImage white_chessman_img = null;// 初始化白棋图片
private BufferedImage black_chessman_img = null;// 初始化黑棋图片
private BufferedImage white_chessbox_img = null;//初始化白棋棋盒
private BufferedImage black_chessbox_img = null;//初始化黑棋棋盒图片
private BufferedImage white_chesshead_img = null;//初始化白棋人物头像
private BufferedImage black_chesshead_img = null;//初始化黑棋人物头像
private BufferedImage bgImage = null;//棋盘背景
private BufferedImage Image = null;//背景图片
private JPanel jp = new JPanel();
private JButton huiqiJButton = new JButton("悔棋");//悔棋按钮
private JButton heqiJButton = new JButton("和棋");
private JButton kaishiJButton = new JButton("开始");
private JButton renshuJButton = new JButton("认输");
private JButton huifangJButton = new JButton("回放");
private JButton beijingyinyueJButton = new JButton("背景音乐");
private JTextField chatJTextField = new JTextField("123455645665") ;
private JButton sendButton = new JButton("发送");
private JTextArea chatJTextArea = new JTextArea("1234561234568568896",10,5) ;
private int[][] chess = new int[16][16];
private boolean isBlack = true ;

//构造方法
public ChessPanel(LoginPanel lp) {
this.lp = lp ;
this.me=lp.me;
initChessPanel();
}

//棋盘面板初始化方法
public void initChessPanel(){
// 取得屏幕的宽度
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
// 取得屏幕的高度
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
//设置窗体布局为空
this.setLayout(null);
//设置窗体标题
this.setTitle("网络五子棋游戏");
//设置窗体位置
this.setLocation((width - 800) / 2, (height - 600) / 2);
//设置窗体大小
this.setSize(800, 600) ;
//设置窗体大小不可改变
this.setResizable(false);
//添加鼠标对窗体的监听
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e){
mousePressedHandle(e);
}
});
//悔棋按钮位置、大小、字体的设置
huiqiJButton.setBounds(20, 525, 70, 30);
huiqiJButton.setFont(new Font("黑体", 1, 16));
this.add(huiqiJButton);
//悔棋按钮
heqiJButton.setBounds(100, 525, 70, 30);
heqiJButton.setFont(new Font("黑体", 1, 16));
this.add(heqiJButton);
//开始按钮
kaishiJButton.setBounds(180, 525, 70, 30);
kaishiJButton.setFont(new Font("黑体", 1, 16));
this.add(kaishiJButton);
//认输按钮
renshuJButton.setBounds(260, 525, 70, 30);
renshuJButton.setFont(new Font("黑体", 1, 16));
this.add(renshuJButton);
//回放按钮
huifangJButton.setBounds(340, 525, 70, 30);
huifangJButton.setFont(new Font("黑体", 1, 16));
this.add(huifangJButton);
//背景音乐按钮
beijingyinyueJButton.setBounds(420, 525, 110, 30);
beijingyinyueJButton.setFont(new Font("黑体", 1, 16));
this.add(beijingyinyueJButton);
//聊天对话框
chatJTextArea.setBounds(600, 150, 180, 330);
chatJTextArea.setFont(new Font("黑体", 1, 16));
chatJTextArea.setLineWrap(true);
chatJTextArea.setEditable(false);
this.add(chatJTextArea);
//消息输入框
chatJTextField.setBounds(550, 500, 150, 30);
chatJTextField.setFont(new Font("黑体", 1, 16));
this.add(chatJTextField) ;
chatJTextField.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent e){
chatJTextFieldHandle(e);
}
});
//消息发送按钮
sendButton.setBounds(710, 500, 70, 30);
sendButton.setFont(new Font("黑体", 1, 16));
this.add(sendButton);
sendButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sendactionPerformed();
}
});
//点击关闭按钮,窗体关闭
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String imagePath = "" ;
try {
imagePath = System.getProperty("user.dir")+"/bin/image/background0.png" ;
Image = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/background.png" ;
bgImage = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/whiteChessman.png" ;
white_chessman_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/blackChessman.png" ;
black_chessman_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/whiteChess.png" ;
white_chessbox_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/blackChess.png" ;
black_chessbox_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/head1.jpg" ;
white_chesshead_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
imagePath = System.getProperty("user.dir")+"/bin/image/head0.jpg" ;
black_chesshead_img = ImageIO.read(new File(imagePath.replaceAll("\\\\", "/")));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("image路径异常");
}
//设置窗体为可见
this.setVisible(true) ;
}

//重写绘图方法
public void paint(Graphics g){
g.setColor(Color.BLACK);
// 绘制背景
g.drawImage(Image, 0, 0, 800,600,this);
g.drawImage(bgImage, 18, 48, 493,496,this);
g.drawImage(black_chesshead_img, 520, 180, 80,80,this);
g.drawImage(black_chessbox_img, 540, 270, 40,40,this);
g.drawImage(white_chesshead_img, 520, 320, 80,80,this);
g.drawImage(white_chessbox_img, 540, 410, 40,40,this);
// 绘制棋盘
for (int i = 0; i < 16; i++) {
g.drawLine(40, 70 + 30 * i, 490, 70 + 30 * i);
g.drawLine(40 + 30 * i, 70, 40 + 30 * i, 520);
}

//绘制棋子
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if(chess[x][y] == 1){
g.drawImage(black_chessman_img, x*30+40-15,  y*30+70-15, 30, 30, this);
}
else if(chess[x][y] == 2){
g.drawImage(white_chessman_img, x*30+40-15,  y*30+70-15, 30, 30, this);
}
}
}
//玩家信息显示
g.setFont(new Font("微软雅黑", Font.BOLD, 18));
g.drawString("本家信息:", 530, 60);
g.drawString("对家信息:", 650, 60);
g.setFont(new Font("微软雅黑", Font.BOLD, 12));
g.drawString("昵称:" + me.getName(), 530, 90);
g.drawString("IP:" + me.getIp(), 530, 120);
g.drawString("联机时间:" + me.getTime(), 530, 150);
g.drawString("昵称:" + user.getName(), 650, 90);
g.drawString("IP:" + user.getIp(), 650, 120);
g.drawString("联机时间:" + user.getTime(), 650, 150);

//设置窗体为可见
this.setVisible(true) ;
} public void mousePressedHandle(MouseEvent e) {
// TODO Auto-generated method stub
  x = e.getX();
  y = e.getY();
  System.out.println("X:"+e.getX()); 
  System.out.println("Y:"+e.getY());
  //只有鼠标点击棋盘时才执行
  if(x>25&&x<505&&y>55&&y<535){
  
  x = (x - 40 + 15)/30 ;
  y = (y - 70 + 15)/30 ;
  if(isBlack){
  chess[x][y] = 1;
  isBlack = false;
  }
  else {
  chess[x][y] = 2;
  isBlack = true;
  }
  repaint();
  }
}


public void sendactionPerformed(){
String message = (String)chatJTextField.getText();
if(message==null||message.isEmpty()){
return ;
}
chatJTextField.setText("");
appendMessage("张三:" + message);
lp.send(message);
}

public void chatJTextFieldHandle(KeyEvent e){
if(e.getKeyChar()=='\n'){
sendButton.doClick();
}
}

private void appendMessage(String message) {
chatJTextArea.append("\n" + message);
System.out.println(message);
} public void setTowardsUser(Player user){

}

}