The IDE provides several mechanisms to make it easier to view and navigate a given Java file:
Viewing and Navigating Members of a ClassThe IDE's Navigator window (shown in Figure 5-10) provides a list of all "members" (constructors, methods, and fields) of your class. You can double-click a member in this list to jump to its source code in the Source Editor. Alternatively, instead of using the mouse, press Ctrl-7 to give focus to the Navigator window. Then begin typing the identifier until the Navigator locates it and press Enter to select that identifier in the Source Editor. Figure 5-10. Navigator window
You can use the filter buttons at the bottom of the window to hide non-public members, static members, fields, and/or inherited members. Moving the Insertion Point and Scrolling the WindowThere is a wide range of shortcuts that you can use for moving the insertion point around and scrolling the Source Editor without moving the insertion point. See Table 5-5 for a list of some of the most useful file navigation shortcuts. Bookmarking Lines of CodeYou can set bookmarks in files to make it easy to find an area of the file that you are working with frequently. You can then cycle through the file's bookmarks by pressing F2 (next bookmark) or Shift-F2 (previous bookmark). To bookmark a line in a file, click in the line and press Ctrl-F2. To remove a bookmark, also use Ctrl-F2. Hiding Sections of CodeYou can collapse (or fold) low-level details of code so that only one line of that block is visible in the Source Editor, leaving more room to view other lines. Methods, inner classes, import blocks, and Javadoc comments are all foldable. Collapsible blocks of code are marked with the icon in the left margin next to the first line of the block. The rest of the block is marked with a vertical line that extends down from the icon. Collapsed blocks are marked with the icon. You can click one of these icons to fold or expand the particular block it represents. See Figure 5-11 for an example. Figure 5-11. Examples of expanded and folded code in the Source Editor
You can also collapse and expand single or multiple blocks of code with keyboard shortcuts and menu items in the Edit | Code Folds menu and the Code Folds submenu in the Source Editor. See Table 5-6 for a list of these commands and shortcuts.
By default, none of the code that you write is folded. You can configure the Source Editor to fold Java code by default when you create a file or open a previously unopened file. To configure the IDE to fold certain elements of Java code automatically:
|