ボタンをクリックすると、プログラムは新しい JPanel オブジェクトを初期化し、すぐにペイントしようとします。repaint() の後、サーバーへのソケットを開き、いくつかの対話を実行します。私が抱えている問題は、ソケットの相互作用が完了するまで repaint() が画面を描画しないことです。これがコードです。
GameGUI JPanel オブジェクトの作成
this.startmenu.setVisible(false);
//startmenu is what the user looks at prior to clicking the button
this.game = new GameGUI(this, this.saver,
new Player(this.startmenu.getPlayerDataSelection()), in);
this.game.run();//performs the socket interactions
GameGUI JPanel オブジェクトの構築
this.game = new PlayingFieldGUI();
//this is a panel inside the panel
this.setLayout(new FlowLayout());
//just need game panel and users panel side by side
this.add(this.game);
this.client.add(this);//client is the jpanel that holds this
this.setVisible(true);
this.game.setVisible(true);
this.client.repaint();//attempting to repaint
このrun()
関数は、 の背景をペイントしますGameGUI
。ソケット呼び出しを実行すると、背景が適切に描画されます。ソケットがやり取りしているサーバーをやり取りの途中でkillしてしまうと、GameGUIの構築時に発生するはずだった描画とともに例外がスローされます。