Set a Breakpoint

Make a Query Tutorial Contents Step in Source Code

Now you're going to track down a bug in the source code.

  1. Run the applet by clicking the Run button.

    Run also detects and compiles changed files. In this case there are no changes. The Java Applet Viewer is displayed alongside your Cosmo Code window.

    <PIC>

  2. Move the cursor over the icon in the Applet Viewer.

    Notice that the width of the menu outline is narrower than the menu text. You need to find the location where the menu width is set and make it the correct width. The menu width for this applet changes depending on how wide the menu items are, so you need to step through some code to figure out how the menu width is being set.

    But first, setting line numbers is useful when debugging.

  3. Choose Debug > Terminate All Threads.

  4. Choose File > Preferences.

  5. From the Reference Category option menu, choose Source.

  6. Make sure that the Show Line Numbers option is checked and click OK.

    <PIC>

    Now search for possible locations where the width of the menu is set.

  7. Scroll to the top of the source file and click in the first line.

  8. Choose Search > Find.

  9. In the dialog, check the Keep Dialog option so that the dialog stays open after the first search.

  10. Type width in the text field and click Find.

    The first match shows a declaration for buttonwidth, an unlikely candidate.

  11. Click the Find button again.

    The second match shows a declaration for menuwidth, which is what you are looking for. You can now refine the search by looking for occurrences of menuwidth.

  12. Type menuwidth in the text field in the Find dialog, and click Find again.

    This takes you to the location where the width of the menu is calculated.

  13. Close the Find Dialog.

  14. Move the cursor into the Annotation column where line numbers are displayed and click next to line 61.

    <PIC with breakpoint set>

    A round icon appers in the Annotation column at line 61 to show that a breakpoint has been set.

    Make a Query Tutorial Contents Step in Source Code

    Guide to the Cosmo Code Development Environment
    12-96*159