Stepping Through the Code

See Also

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. From the Source Editor toolbar, select the initComponents method from the combo box.

    The cursor appears at the beginning of the initComponents method.

  2. Add a breakpoint by clicking the left margin of the line containing the initComponents method (on or about line 25).
  3. The line is highlighted to indicate that a breakpoint was set.

    Alternatively, you can set a line breakpoint by choosing Debug and chooose New Breakpoint from the main IDE window. The New Breakpoint dialog box allows you to add different types of breakpoints and configure the breakpoint's settings.

  4. Choose Debug and chooose Step Into.

    A debugging session begins and the first line in the main method is highlighted. The IDE switches to the debugging workspace, which displays:

  5. Remove the breakpoint by clicking the left margin of the line with the initComponents method in the Source Editor (on or about line 25).

    The breakpoint is removed.

    Alternatively, click the line with the breakpoint and choose Debug and chooose Toggle Breakpoint from the main menu.

  6. Choose Debug > Step Into or press F7 another time to see the debugger step into the source code.
  7. The Call Stack view is updated.

  8. 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
See Also
Debugging Programs
Current Context in the Debugger
Setting Breakpoints

Legal Notices