调试Java程序。使用Netbeans IDE 7.1

调试Java程序。使用Netbeans IDE 7.1,java,debugging,netbeans-7.1,Java,Debugging,Netbeans 7.1,我使用的是Netbeans IDE 7.1,我试图调试我的简单程序,在变量输出窗口中,有一条消息指出没有要显示的变量,因为没有当前线程。这是什么意思?谢谢 这是我的密码: public class SwingExercise { public static void main(String[] args) { String name = ""; String pw = ""; boolean input = true; boolean hasDigit =

我使用的是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 = "";
        }
    }
}

}

因此,在代码执行暂停时,您只能通过断点或在调试时按“暂停”来查看变量。然后,您可能还需要从左侧的线程列表中选择程序的主线程。此时,变量应该显示出来