0
我已經縮小了我的問題:如果我使用掃描儀,則不會出現JOptionPane。例如,這工作得很好:爲什麼我在使用掃描儀時未出現JOptionPane?
public static void main(String[] args) {
System.out.println("Before the dialog.");
JOptionPane.showMessageDialog(null, "Please.");
System.out.println("After the dialog.");
}
即使這樣的作品,太:
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Before the dialog.");
JOptionPane.showMessageDialog(null, "Please.");
System.out.println("After the dialog.");
}
但是,這並不工作:
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int hi = butler.nextInt();
System.out.println("Before the dialog.");
JOptionPane.showMessageDialog(null, "Please.");
System.out.println("After the dialog.");
}
在最後一個例子,程序等待輸入,然後顯示「在對話框之前」。之後,該計劃似乎凍結。
我試圖在創建對話框之前關閉掃描儀,但沒有任何效果。
適合我。也許你的實際代碼是不同的。請參閱http://stackoverflow.com/help/mcve。 – Radiodef
你在使用IDE嗎? JOptionPane是否隱藏在IDE接口後面,因爲IDE由於輸入而具有焦點? – copeg