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 25 in the Source Editor, which contains the initComponents method.
  3. Choose Debug and chooose Add Breakpoint from the main window. Click OK in the Add Breakpoint dialog box.

    The line is highlighted to indicate that a breakpoint was set.

  4. Choose Debug and chooose Step Into.

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

    The next method call is highlighted.

    The first line in the main method is highlighted.

  5. In the Source Editor, click the line with the initComponents method. Choose Debug and chooose Toggle Breakpoint.

    The breakpoint is removed.

  6. Finally, choose Debug and chooose Finish. Click OK in the Finish debugging sessions dialog box to end the debugging session.

You have now completed the ColorSwitch tutorial.

Back:  Compiling and Running Your Program

Legal Notices