1
我正在使用Netbeans IDE 7.1,並且我試圖調試我的簡單程序,並且在變量輸出窗口中,有一條消息說明「沒有要顯示的變量,因爲沒有當前線程。」這是什麼意思?謝謝。 :)調試Java程序。使用Netbeans IDE 7.1
這裏是我的代碼:
public class SwingExercise {
public static void main(String[] args) {
String name = "";
String pw = "";
boolean input = true;
boolean hasDigit = true;
while (input) {
try {
while (name.equals("")) {
name = JOptionPane.showInputDialog(null, "Enter username:");
if (name.equals("")) {
JOptionPane.showMessageDialog(null, "No input.", "Error", JOptionPane.ERROR_MESSAGE);
name = "";
}
while (hasDigit) {
for (int i = 0; i < name.length(); i++) {
if (Character.isDigit(name.charAt(i))) {
throw new InputMismatchException();
}
}
hasDigit = false;
}
}
while (pw.equals("")) {
pw = JOptionPane.showInputDialog(null, "Enter password:");
if (pw.equals("")) {
JOptionPane.showMessageDialog(null, "No input.", "Error", JOptionPane.ERROR_MESSAGE);
pw = "";
}
}
} catch (NullPointerException e) {
System.exit(0);
} catch (InputMismatchException e) {
JOptionPane.showMessageDialog(null, "Invalid input.", "Error",
JOptionPane.INFORMATION_MESSAGE);
name = "";
}
}
}
}