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:
- Go back to the GUI editing workspace by clicking the GUI Editing workspace
button in the main window.
- Click line 25 in the Source Editor, which contains the initComponents
method.
- Choose Debug
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.
- Choose Debug
Step Into.
A debugging session begins and the program runs until it reaches the breakpoint.
The IDE switches to the debugging workspace, which displays:
- Information about the breakpoint on the Breakpoints tab in the Debugger
window
- Messages from the debugger in the Output window
The next method call is highlighted.
The first line in the main method is highlighted.
- In the Source Editor, click the line with the initComponents method.
Choose Debug
Toggle
Breakpoint.
The breakpoint is removed.
- Finally, choose Debug
Finish. Click
OK in the Finish debugging sessions dialog box to end the debugging session.
You have now completed the ColorSwitch tutorial.
Legal Notices