2012-03-27 65 views
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 = ""; 
     } 
    } 
} 

}

回答

0

所以你只能看到變量,而代碼執行或者通過斷點或者通過你按下暫停在調試暫停。然後,您可能還必須從左側的線程列表中選擇程序的主線程。此時,變量應該顯示出來。