I have a strange problem in my current code: When I call Controls.requestKeyChange from MenuController.changeControls, it just seems to return from changeControls.
My code:
MenuController.java:
public class MenuController extends AbstractAppState implements ScreenController{
//...
public void changeControls(String s){
ControlsButton1.setText("Press any button...");
System.out.println("changeControls in MenuController called (Action: "+Controls.Action.values()[Integer.parseInt(s)]+" )");
Controls.requestKeyChange(Controls.Action.values()[Integer.parseInt(s)], app.getInputManager(), new Runnable() {
public void run() {
ControlsButton1.setText(Controls.keyName);
}
});
}
}
Controls.java:
public class Controls implements ActionListener{
//...
public static void requestKeyChange(Action action,InputManager im, Runnable executeWhenDone){
System.out.println("requestKeyChange called (Arguments: "+action+", "+im+", "+executeWhenDone);
r = executeWhenDone;
removeControls(im);
setupKeyNames();
for(int i=0; i<keyCodes.size(); i++){
im.addMapping(keyNames.get(i), keyboard.get(i) ? new KeyTrigger(keyCodes.get(i)) : new MouseButtonTrigger(keyCodes.get(i)));
}
System.out.println(im.toString());
changingControls = true;
}
}
Console output:
//...
changeControls in MenuController called (Action: moveUp )
BUILD SUCCESSFUL (total time: 20 seconds)
Does anyone know why this happens?