Chapter 5. Editing and Refactoring Code


  • Opening the Source Editor

  • Managing Automatic Insertion of Closing Characters

  • Displaying Line Numbers

  • Inserting Snippets from Code Templates

  • Using Editor Hints to Generate Missing Code

  • Matching Other Words in a File

  • Generating Methods to Implement and Override

  • Creating and Using Macros

  • Creating and Customizing File Templates

  • Handling Imports

  • Displaying Javadoc Documentation While Editing

  • Formatting Code

  • Text Selection Shortcuts

  • Navigating within the Current Java File

  • Navigating from the Source Editor

  • Searching and Replacing

  • Refactoring Commands

  • Deleting Code Safely

  • Extracting a Superclass to Consolidate Common Methods

  • Changing References to Use a Supertype

  • Unnesting Classes

  • Tracking Notes to Yourself in Your Code

  • Comparing Differences Between Two Files

  • Splitting the Source Editor

  • Maximizing Space for the Source Editor

  • Changing Source Editor Keyboard Shortcuts

NETBEANS IDE PROVIDES A WIDE VARIETY OF TOOLS to support Java application development, but it is the Source Editor where you will spend most of your time. Given that fact, a lot of attention has been put into features and subtle touches to make coding faster and more pleasurable.

Code completion and other code generation features help you identify code elements to use and then generate code for you. Refactoring features enable you to easily make complex changes to the structure of your code and have those changes propagated throughout your project. Keyboard shortcuts for these code generation features and for file navigation ensure that your hands rarely have to leave the keyboard.

Architecturally, the Source Editor is a collection of different types of editors, each of which contains features specific to certain kinds of files. For example, when you open a Java file, there is a syntax highlighting scheme specifically for Java files, along with code completion, refactoring, and other features specific to Java files. Likewise, when you open JSP, HTML, XML, .properties, deployment descriptor, and other types of files, you get a set of features specific to those files.

Perhaps most importantly, the Source Editor is tightly integrated with other parts of the IDE, which greatly streamlines your workflow. For example, you can specify breakpoints directly in the Source Editor and trace code as it executes. When compilation errors are reported in the Output window, you can jump to the source of those errors by double-clicking the error or pressing F12.

In this chapter, we will demonstrate the ways you can use the IDE's editing features to simplify and speed common coding tasks.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net