I have a GameEngine class that waits for the UserInterface class to change its aField attributes. While it is null, it stays in the while loop, but whenever aField changes processCommand() is supposed to exit the loop. An action performed in UserInterface changes this attribute (aField appears changed through a System.out.println), but the while loop is not exited. Here is the code :
Game Engine class :
public String processCommand(){
while(aGui.getField()==null) {
}
String a = aGui.getField();
aGui.setCommand(null);
System.out.println("a :"+a +".");
return a;
}
User Interface class:
public void actionPerformed(final ActionEvent pE){
this.processCommandUI();
}
public void processCommandUI(){
try{
String vInput = this.aEntryField.getText();
this.aEntryField.setText("");
aField=vInput;
System.out.println(aField);
}
catch (Exception e) {
System.out.println("Erreur");
}
}
I tried to change the attribute to an int but it did not change anything.