As said on my title, my showConfirmDialog never waits for a "Yes" or "No" button press whenever I call it.
Originally I encountered a bug that involved me getting blank JOptionPanes
, so now I'm using the invokeLater
method. I'm not too familiar with the concept so I apologize beforehand.
public int firstGame()
{
SwingUtilities.invokeLater(new Runnable() {
public void run() {
yOrN = JOptionPane.showConfirmDialog(null,
"Are you ready to play?\n", "Play?", JOptionPane.YES_NO_OPTION);
}
});
return yOrN;
// will return 0 if yes and 1 if no.
}
Before using invokeLater
, it was working fine (except for the blank JOptionPane
s). Does this method run another thread? Howcome my showInputDialog
waits for an input and not this one?