prefer invokeLater
parent
580e82c345
commit
23cfe45d4e
|
@ -65,11 +65,19 @@ public class GameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableForwardButton() {
|
public void enableForwardButton() {
|
||||||
gameViewer.enableButton(IconImages.FORWARD);
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
gameViewer.enableButton(IconImages.FORWARD);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableActionButton(final boolean thinking) {
|
public void disableActionButton(final boolean thinking) {
|
||||||
gameViewer.disableButton(thinking);
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
gameViewer.disableButton(thinking);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true when undo was clicked. */
|
/** Returns true when undo was clicked. */
|
||||||
|
@ -253,18 +261,13 @@ public class GameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showValidChoices() {
|
private void showValidChoices() {
|
||||||
try {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
public void run() {
|
||||||
public void run() {
|
for (final ChoiceViewer choiceViewer : choiceViewers) {
|
||||||
for (final ChoiceViewer choiceViewer : choiceViewers) {
|
choiceViewer.showValidChoices(validChoices);
|
||||||
choiceViewer.showValidChoices(validChoices);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} catch (final Throwable th) {
|
});
|
||||||
//there will be an error if X windows is not present
|
|
||||||
System.err.println("ERROR! showValidChoices threw an exception/error");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCombatChoice() {
|
public boolean isCombatChoice() {
|
||||||
|
@ -289,28 +292,12 @@ public class GameController {
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
//invokeAndWait(new Runnable() {
|
|
||||||
public void run() {
|
public void run() {
|
||||||
gamePanel.update();
|
gamePanel.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invokeAndWait(final Runnable task) {
|
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
|
||||||
task.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
SwingUtilities.invokeAndWait(task);
|
|
||||||
} catch (InterruptedException err) {
|
|
||||||
throw new RuntimeException(err.getMessage());
|
|
||||||
} catch (InvocationTargetException err) {
|
|
||||||
throw new RuntimeException(err.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessageWithSource(final MagicSource source,final String message) {
|
public String getMessageWithSource(final MagicSource source,final String message) {
|
||||||
if (source==null) {
|
if (source==null) {
|
||||||
return message;
|
return message;
|
||||||
|
@ -395,7 +382,6 @@ public class GameController {
|
||||||
if (resetGame) {
|
if (resetGame) {
|
||||||
resetGame=false;
|
resetGame=false;
|
||||||
while (game.hasUndoPoints()) {
|
while (game.hasUndoPoints()) {
|
||||||
|
|
||||||
game.gotoLastUndoPoint();
|
game.gotoLastUndoPoint();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue