I'm stuck on this since almost 5 hours and I cannot find any answer.
Here is the piece of code you need.
Client.java
public class Client {
private GUI _GUI = new GUI();
public Client() {
}
public void Run() throws Exception {
_GUI.Run();
System.out.println("before");
while (_GUI.isOver() == false)
{
System.out.println("azerty");
}
System.out.println("after");
_GUI.Stop();
}
}
GUI.java
public class GUI {
final static String STARTPANEL = "startpanel";
final static String LOBBYPANEL = "lobbypanel";
final static String GAMEPANEL = "gamepanel";
final static String ENDPANEL = "endpanel";
private JFrame _MainWindow = new JFrame();
private CardLayout _MainLayout = new CardLayout();
private JPanel _MainPanel = new JPanel(_MainLayout);
public GUI() {
InitWindow();
InitPanelLayout();
}
public void Run() {
}
public void Stop() {
_MainWindow.dispose();
}
private void InitWindow() {
_MainWindow.setTitle("Mille Borne");
_MainWindow.setSize(1020, 920);
_MainWindow.setResizable(false);
_MainWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
_MainWindow.setLocationRelativeTo(null);
_MainWindow.setVisible(true);
}
private void InitPanelLayout() {
_MainWindow.add(_MainPanel);
//_MainPanel.add(STARTPANEL);
//_MainPanel.add(LOBBYPANEL);
//_MainPanel.add(GAMEPANEL);
//_MainPanel.add(ENDPANEL);
}
public boolean isOver() {
if (_MainWindow.isVisible() == true) {
return (false);
}
return (true);
}
}
If I remove this line in the Client.java
System.out.println("azerty");
The program is not exiting the loop, the "after" is not displayed.
Can someone explain me what is going on ?
Thanks for your help !