Instead of wait()
, use JOptionPane.showInputDialog(...)
, like here:
import javax.swing.JOptionPane;
public class LanguagesSelector{
public static void main(String[] args) {
String[] languages = {"Spanish", "English", "Italian", "Other"};
Object language = JOptionPane.showInputDialog(null,
"Choose Language", "language", JOptionPane.PLAIN_MESSAGE,
null, languages, languages[0]);
System.out.println("Selected " + language);
}
}
In JOptionPane
class, the AWT (whom swing base on) thread wait for the user choose an option, so it is should work in your issue.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…