【发布时间】:2022-12-17 00:04:13
【问题描述】:
此代码是客户端的一部分。从服务器获取信息的部分正在工作,但它没有调用重绘函数(第 6 行)。
public class Client extends JPanel implements Runnable{
public Client() throws IOException{
f = new JFrame("Bad Ice Cream by - Rotem Hanoch");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(this.width,this.height);
f.setResizable(false);
f.setFocusable(false);
f.setVisible(true);
initBoard();
f.add(this);
}
public void run(){
while(true){
try {
Board.Type mat[][] = (Board.Type[][]) this.objectInputStream.readObject();
updateBoard(mat);
this.repaint();
} catch (IOException ex) {} catch (ClassNotFoundException ex) {}
}
}
public void paintComponent(Graphics g){
System.out.println("hello");
}
}
我试图弄清楚为什么它不起作用,因为它无法识别该功能。我希望它给我打印一条消息,这样我就知道它已经达到了功能。
【问题讨论】:
标签: java client jpanel paintcomponent repaint