1

I am using Netbeans IDE 7.1, and I was trying to debug my simple program and on the Variable Output Window, there is a message which states "No variables to display because there is not current thread." What does it mean? Thanks. :)

Here's my code:

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 = "";
        }
    }
}

}

Layne
  • 25
  • 1
  • 5

1 Answers1

0

So you can only see variables while code execution is suspended either through a breakpoint or through you pressing pause while debugging. Then, you may also have to select the program's main thread from the list of threads on the left. At that point, the variables should show up.

Zarkonnen
  • 22,200
  • 14
  • 65
  • 81