Stepping Through the Code

Using the debugger, you can locate and correct bugs in your program. The following steps introduce you to debugging in the IDE.

To step through the code:

  1. Go back to the GUI editing workspace by clicking the GUI Editing workspace button in the main window.

  2. Click line 26 in the Source Editor, which contains the initComponents method.

  3. Choose Debug Add/Remove Breakpoint.

    The line is highlighted to indicate a breakpoint was set.

  4. Next choose Debug Start Debugger.

    The program runs until it reaches the breakpoint. The IDE switches to the debugging workspace, which displays:

    The next method call is highlighted.

  5. Choose Debug Step Out.

    The first line in the main method is highlighted.

  6. In the Source Editor, click the line with the initComponents method and then choose Debug Add/Remove Breakpoint.

    The breakpoint is removed.

  7. Finally, choose Debug Finish Debugging to end the debugging session.

Next:Viewing the Class Hierarchy
Back:Compiling and Running Your Program

Legal Notices