Skip Headers
NetBeans Developing Applications with NetBeans IDE
Release 7.4

E40142-08
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

2 Working with NetBeans IDE

This chapter describes the basics of using and configuring NetBeans IDE.

This chapter contains the following sections:

2.1 About Working with NetBeans IDE

The IDE enables you to configure options for its many areas of functionality as well as customize its workspace. The primary tools you can use to configure and update the IDE include the following:

You can also pass startup parameters to the IDE launcher in the IDE-HOME/etc/netbeans.conf file by using startup switches. For more information, see Section 2.7, "Setting Startup Parameters".

2.2 Working with the Options Window

The Options window enables you to change any of the IDE's configurable settings. You select a category at the top of the window to display its settings in the lower pane. Depending on the category, you can click on the tabs in the lower pane to access additional settings. The changes are applied when you click Apply.

2.2.1 How to Edit IDE Settings

You use the Options window to specify global settings for the IDE. Settings that you specify at the project level override the settings that you specify in the Options window.

To edit IDE settings in the Options window:

  1. Open the Options window by choosing Tools > Options from the main menu. (If you are running on Mac OS X, choose NetBeans > Preferences.)

  2. Select the category in the upper pane to display the configurable settings.

  3. Modify the settings.

  4. Click Apply.

2.2.2 How to Export IDE Settings as Zip Archive

You can export your IDE settings as an archive that you can use as a backup or that you can import into an installation of the IDE on another machine.

To export IDE settings as a zip archive:

  1. Open the Options window by choosing Tools > Options from the main menu. (If you are running on Mac OS X, choose NetBeans > Preferences.)

  2. Click Export at the bottom of the Options window.

  3. Specify the location and name of the zip archive that you want to create to contain your settings.

  4. Select the Options categories that you want to export. Click OK.

2.2.3 How to Import IDE Settings

When you launch a new version of the IDE for the first time, you are prompted with the option of importing settings from a previous version of the IDE. This prompt occurs only if you have a user directory on your system from the previous version of the IDE and the user directory is in the default location.

The settings that are imported include the following items:

  • Keyboard shortcuts

  • Most Source Editor font and color settings

  • Java Platform Manager contents

  • Library Manager contents

  • Database drivers

  • Servers

You can recreate the conditions of the first launch at any time by deleting your current userdir. When you restart the IDE you will be prompted with the option of importing settings from a previous version of the IDE.

For more details about locating your current userdir, see the following FAQ.

http://wiki.netbeans.org/FaqWhatIsUserdir

Note:

If you delete your userdir you could lose other important settings. In addition, you might also lose any modules you have installed through the Update Center in the new version and you may need to reinstall or reactivate those modules.

If you do not import the settings at the first launch but later decide that you would like to import the settings from a previous installation, you can choose the settings that you would like to import in the Options window.

Importing settings may overwrite your existing settings. To prevent possible loss of your settings, use the Export settings function to create a backup of your IDE settings.

To import IDE settings:

  1. Open the Options window by choosing Tools > Options from the main menu. (If you are running on Mac OS X, choose NetBeans > Preferences.)

  2. Click Import at the bottom of the Options window.

  3. Click Browse and locate either of the following:

    • the zip archive that contains your settings

    • the userdir of the IDE installation that has the settings that you want to import

  4. Select the Options categories that you want to import. Click OK.

You will need to restart the IDE to apply the imported settings.

2.3 Managing IDE Windows

Each window in the IDE appears as a tab in the pane in which it resides. The IDE's windowing system enables you to arrange windows anywhere in the IDE by dragging and dropping. The IDE remembers the position of both manually and automatically closed windows the next time they are opened.

Some windows only appear when you are performing a task to which they are related. For example, the Debugger windows only appear when you are in a debugging session. You can manually open task-related windows so that they are always open.

To open a task-related window, simply choose the window from the Windows menu.

The following table lists some keyboard shortcuts that you can use to navigate, activate and select components in IDE windows.

Table 2-1 Keyboard Shortcut for Managing Windows

Keys Action

Ctrl-0

Switch to Editor window

Ctrl-1

Switch to Project window

Ctrl-2

Switch to Files window

Ctrl-3

Switch to Favorites window

Ctrl-4

Switch to Output window

Ctrl-5

Switch to Services window

Ctrl-6

Switch to Action Items window

Ctrl-7

Switch to Navigator window

Ctrl-Shift-5

Switch to HTTP Monitor window

Ctrl-Shift-7

Switch to Properties window

Ctrl-Shift-1

Select file in Projects window

Ctrl-Shift-2

Select file in Files window

Ctrl-Shift-3

Select file in Favorites window

Ctrl-Shift-8

Opens the Palette

Ctrl-F4

Close window

Ctrl-Shift-F4

Close all documents

Shift-F4

Open Documents dialog box

Shift-Escape

Maximize window

Ctrl-Tab

Switch to recent window

Ctrl-W

Closes the current tab in the current window. If the window has no tabs, the whole window is closed.

Alt-right

Displays the next tab in the current window.

Alt-left

Displays the previous tab in the current window.

Up arrow

Moves keyboard focus to the previous item in a group of items. Navigates to the previous setting in a drop-down list in a property sheet.

Down arrow

Moves keyboard focus to the next item in a group of items. Navigates to the next setting in a drop-down list in a property sheet.

Left arrow

Closes a folder (node).

Right arrow

Opens a folder (node).

F1

Show Help for selected component


2.3.1 How to Move a Window

The windowing system in the IDE enables you to drag window components to any location in the IDE.

To move a window:

  1. Click the window header and drag the window to the desired position. A red preview box indicates the new location of the window after you release it.

  2. Drop the window.

2.3.2 How to Configure Window Behavior and Appearance

How to configure window behavior and appearance

  1. Choose Tools > Options from the main menu.

  2. Click the Windows tab in the Miscellaneous category.

2.3.3 How to Simultaneously Display Multiple Files in the Editor

You can split the Source Editor, which enables you to work with multiple files or different areas of the same file simultaneously. The Source Editor can be split horizontally or vertically.

To simultaneously display multiple files in the Source Editor:

  1. Open two or more files in the Source Editor.

  2. Click the tab of one of the files and drag it to the edge of the Source Editor pane where you want the file to be placed. A red preview box indicates the new position of the window.

  3. Release the mouse button to drop the window when the red preview box indicates the window is in the new desired position.

To create a group of tabs:

  1. Open two or more files in the Source Editor.

  2. Right-click the tab for one of the files and choose New Document Tab Group.

2.3.4 How to Clone the View of a Single File

You can create a clone of a tab if you want to open two tabs with the same file. If you drag one of the tabs to split the editor view or create a tab group you can view different parts of the same file simultaneously.

How to clone a tab:

  1. Right-click the document tab in the Source Editor and choose Clone.

  2. Click the tab of the cloned document and drag it to the part of the window where you want the copy to be placed.

2.3.5 How to Manage Open Files

How to navigate between open files:

  1. Choose Window > Documents from the main menu.

  2. Select a document from the list in the Documents window.

  3. Click Switch to Document.

How to close or save open files:

  1. Choose Window > Documents from the main menu.

  2. Select a document or documents from the list in the Documents window.

    You can use the ctrl and shift keys to select multiple documents.

  3. Click Close Document(s) or Save Document(s).

2.4 Customizing Toolbars in the IDE

The IDE provides comprehensive control over how toolbars are presented. You can add and remove toolbars and position and control the visibility and contents of toolbars. You can also create customized toolbar configurations.

Choose View > Toolbars from the main menu to see a list of the available toolbars. The submenu displays all the toolbars in the IDE.

2.4.1 How to Show or Hide a Toolbar

Toolbars that are currently visible are indicated by a check mark in the Toolbars submenu.

To show or hide a toolbar:

  • Choose View > Toolbars from the main menu and choose a toolbar name in the submenu.
    Alternatively, right-click the empty space in the toolbar area and choose the toolbar name from the pop-up menu.

To find the name of a toolbar, rest the pointer on the textured drag area of the toolbar to display a tool tip with the toolbar name.

2.4.2 How to Move a Toolbar

To move a toolbar:

  • Click in the textured drag area on the left side of the toolbar and drag the toolbar to the desired location.

2.4.3 How to Add a Toolbar Button to a Toolbar

You can add buttons for many IDE commands and actions to the toolbar of the IDE.

To add a toolbar button to a toolbar:

  1. Choose View > Toolbars > Customize to open the Customize Toolbars window.

  2. Select the button of the action you want to add to the IDE toolbar and drag and drop the button onto the toolbar in the main window.

2.4.4 How to Remove a Button from a Toolbar

The Customize Toolbars window must be open when you are removing toolbar buttons.

To remove a toolbar button from a toolbar:

  1. Choose View > Toolbars > Customize to open the Customize Toolbars window.

  2. In the main window, click and drag the toolbar button above the toolbar. Alternatively, you can drag the button from the toolbar into the Customize Toolbars window.

2.4.5 How to Reorder a Button in a Toolbar

You can customize the order that buttons appear in the toolbar.

To reorder a button in a toolbar:

  1. Choose View > Toolbars > Customize to open the Customize Toolbars window.

  2. In the main window, drag and drop the button to the desired position.

2.4.6 How to Change the Size of Toolbar Buttons

You can select either small or large icons for the toolbar buttons.

To change the size of toolbar buttons:

  • Choose View > Toolbars > Small Toolbar Icons
    Alternately, right-click the empty space in the toolbar area and choose Small Toolbar Icons from the popup menu.

2.4.7 How to Add a New Toolbar to the Main Window

You can create custom toolbars to group sets of buttons.

To add a new toolbar to the main window:

  1. From the main window, choose View > Toolbars > Customize.

  2. In the Customize Toolbars window, click New Toolbar.

  3. In the New Toolbar dialog box, type a name for the toolbar and click OK.

  4. Drag icons from the Customize Toolbars window into the new toolbar.

The new toolbar must have at least one icon.

2.5 Working with Keyboard Shortcuts

You can edit keyboard settings for individual commands or switch between preconfigured sets of keyboard shortcuts. The shortcut sets are designed for users that are already used to the keyboard shortcuts of other editors and IDEs.

2.5.1 How to Add or Remove a Keyboard Shortcut for a Menu Command

You can use the Options window to customize the keyboard shortcuts for menu commands.

To add or remove a keyboard shortcut for a menu command:

  1. From the main window, choose Tools > Options.

  2. Click Keymap in the Options window.

  3. Locate the command for which you want to change a keyboard shortcut.

  4. Double-click in the text field in the Shortcut column of the command and type the new keyboard shortcut.

As you press the key sequence, the correct syntax for that sequence automatically appears in the text field. If you simultaneously hold down the Alt key, the Control key, and the J key, "Alt+Ctrl+J" appears. You can only specify a keyboard shortcut that is not being used by another command.

Note:

To set keyboard shortcuts for recorded macros, go to Editor > Macros in the Options window, select the macro name and edit the keyboard shortcut.

2.5.2 How to Switch Between Keyboard Shortcut Sets

You can use the Options window to switch between any of the existing keyboard shortcuts sets. The IDE includes several sets of keyboard shortcuts with shortcut mappings that correspond to the shortcuts in other editors and IDEs.

To switch between keyboard shortcut sets:

  1. From the main window, choose Tools > Options.

  2. Click Keymap in the Options window.

  3. Choose an existing keyboard set from the Profiles drop-down list at the top of the dialog box.

2.5.3 How to Create a New Keyboard Shortcut Set

You can configure the IDE to have multiple sets of keyboard shortcuts. You can use the Options window to create custom sets of keyboard shortcuts.

To create a new keyboard shortcut set:

  1. From the main window, choose Tools > Options.

  2. Click Keymap in the Options window.

  3. Choose an existing keyboard set from the Profiles drop-down list at the top of the dialog box.

  4. Click Duplicate to duplicate the currently selected shortcut set. Then edit the shortcuts in the new copy.

2.5.4 How to Use the Default Menu Shortcuts

There are keyboard shortcuts available to activate the following menu commands and other general commands:

Table 2-2 File Menu

Keys Command Action

Ctrl-Shift-N

New

Creates a new project with the New Project wizard.

Ctrl-N

New

Creates a new file with the New File wizard.

Ctrl-Shift-O

Open File

Opens an existing project.

Ctrl-S

Save

Saves the current file.

Ctrl-Shift-S

Save All

Saves all files.

Ctrl-Alt-Shift-P

Print

Print the current file.


Table 2-3 Edit Menu

Keys Command Action

Ctrl-Z

Undo

Reverses (one at a time) a series of editor actions, except Save.

Ctrl-Y

Redo

Reverses (one at a time) a series of Undo commands.

Ctrl-X

Redo

Reverses (one at a time) a series of Undo commands.

Ctrl-C

Copy

Copies the current selection to the clipboard.

Ctrl-V

Paste

Pastes the contents of the clipboard into the insertion point.

Ctrl-Shift-V

Paste Formatted

Pastes the formatted contents of the clipboard into the insertion point.

Delete

Delete

Deletes the current selection.

Select All

Ctrl-A

Selects everything in the current document or window.

Select Identifier

Alt-Shift-J

Selects the current identifier.

Ctrl-F3

Find Selection

Finds instances of the current selection.

F3

Find Next

Finds next instance of found text.

Shift-F3

Find Previous

Finds previous instance of found text.

Ctrl-F

Find

Finds previous instance of found text.

Ctrl-H

Replace

Finds a string of text and replaces it with the string specified.

Alt-F7

Find Usages

Finds usages and subtypes of selected code.

Ctrl-Shift-F

Find in Projects

Finds specified text, object names, object types within projects.

Ctrl-Shift-H

Replace in Projects

Replaces text, object names, object types within projects.


Table 2-4 View Menu

Keys Command Action

Ctrl-Minus

Collapse Fold

If the insertion point is in a foldable section of text, collapses those lines into one line.

Ctrl-Plus

Expand Fold

If the currently selected line in the Source Editor represents several folded lines, expands the fold to show all of the lines.

Ctrl-Shift-Minus

Collapse All

Collapses all foldable sections of text in the Source Editor.

Ctrl-Shift-Plus

Expand All

Expands all foldable sections of text in the Source Editor.

Alt-Shift-Enter

Full Screen

Expand window to full length and breadth of screen.


Table 2-5 Navigate Menu

Keys Command Action

Alt-Shift-O

Go to File

Find and open a specific file.

Ctrl-O

Go to Type

Find and open a specific class or interface.

Ctrl-Alt-Shift-O

Go to Symbol

Find and open a specific symbol.

Alt-Shift-B

Go to Spring Bean

Find and open a specific Spring bean.

Ctrl-Shift-T

Go to Test

Find and open a specific test.

Ctrl-Back Quote

Go to Previous Document

Open the document last opened before the current one.

Ctrl-Shift-B

Go to Source

Displays the source file containing the definition of the selected class.

Ctrl-B

Go to Declaration

Jump to the declaration of the item under the cursor.

Ctrl-Shift-P

Go to Super Implementation

Jump to the super implementation of the item under the cursor.

Ctrl-Q

Last Edit Location

Scroll the editor to the last place where editing occurred.

Alt-Left

Back

Navigate back

Alt-Right

Forward

Navigate forward

Ctrl-G

Go to Line

Jump to the specified line.

Ctrl-Shift-M

Toggle Bookmark

Set a bookmark on a line of code.

Ctrl-Shift-Period

Next Bookmark

Cycle forward through the bookmarks.

Ctrl-Shift-Comma

Previous Bookmark

Cycle backwards through the bookmarks.

Ctrl-Period

Next Error

Scrolls the Source Editor to the line that contains the next build error.

Ctrl-Comma

Previous Error

Scrolls the Source Editor to the line that contains the previous build error.

Ctrl-Shift-1

Select in Projects

Opens Projects window and selects current document within it.

Ctrl-Shift-2

Select in Files

Opens Files window and selects current document within it.

Ctrl-Shift-3

Select in Favorites

Opens Favorites window and selects current document within it.


Table 2-6 Source Menu

Keys Command Action

Alt-Shift-F

Format

Formats the selected code or the entire file if nothing is selected.

Alt-Shift-Left

Shift Left

Moves the selected line or lines one tab to the left.

Alt-Shift-Right

Shift Right

Moves the selected line or lines one tab to the right.

Alt-Shift-Up

Move Up

Moves the selected line or lines one line up.

Alt-Shift-Down

Move Down

Moves the selected line or lines one line down.

Ctrl-Shift-Up

Duplicate Up

Copy the selected line or lines one line up.

Ctrl-Shift-Down

Duplicate Down

Copy the selected line or lines one line down.

Ctrl-Slash or Ctrl-Shift-C

Toggle Comment

Toggles the commenting out of the current line or selected lines.

Ctrl-Space

Complete Code

Shows the code completion box.

Alt-Insert

Insert Code

Pops up a context aware menu that you can use to generate common structures such as constructors, getters, and setters.

Alt-Enter

Fix Code

Display editor hints. The IDE informs you when a hint is available when the light bulb is displayed.

Ctrl-Shift-I

Fix Imports

Generates the import statements required by the classes specified in the file.

Ctrl-P

Show Method Parameters

Selects the next parameter. You must have a parameter selected (highlighted) for this shortcut to work.

Ctrl-Shift-Space

Show Documentation

Show documentation for item under the cursor.

Ctrl-Shift-K

Insert Next Matching Word

Generates the next word used elsewhere in your code as you type its beginning characters.

Ctrl-K

Insert Previous Matching Word

Generates the previous word used elsewhere in your code as you type its beginning characters.


Table 2-7 Refactor Menu

Keys Command Action

Ctrl-R

Rename

Inplace rename.

Ctrl-M

Move

Inplace move.

Alt-Delete

Safely Delete

Before deleting, display references.


Table 2-8 Run Menu

Keys Command Action

F6

Run Project

Runs the main project or the currently selected project if no main project is set.

Alt-F6

Test Project

Starts unit test for project.

F11

Build Project

Builds the main project or the currently selected project if no main project is set.

Shift-F11

Clean and Build Project

Deletes all previously compiled files and distributable outputs and builds the main project or the currently selected project if no main project is set.

Shift-F6

Run File

Runs the currently selected file.

Ctrl-F6

Test File

Starts unit test for current file.

F9

Compile File

Compiles the file. If you select a folder, the IDE compiles only the files that are new or have changed since the last compile.

Alt-F9

Check File

Checks file dependencies in the currently selected project when building.

Alt-Shift-F9

Validate File

Validates file dependencies in the currently selected project when building.

Ctrl-F11

Repeat Build/Run

Runs/builds the currently selected project once again.


Table 2-9 Debug Menu

Keys Command Action

Ctrl-F5

Debug Project

Debugs the main project or the currently selected project if no main project is set.

Ctrl-Shift-F5

Debug File

Starts debugging session for currently selected file.

Ctrl-Shift-F6

Debug Test File

Starts debugging test for file.

Shift-F5

Finish Debugger Session

Ends the debugging session.

F5

Continue

Resumes debugging until the next breakpoint or the end of the program is reached.

F8

Step Over

Executes one source line of a program. If the line is a method call, executes the entire method then stops.

Shift-F8

Step Over Expression

Steps over the expression and then stops the debugging.

F7

Step Into

Executes one source line of a program. If the line is a method call, executes the program up to the method's first statement and stops.

Shift-F7

Step into Next Method

Runs the current project to the specified method and then steps into the method.

Ctrl-F7

Step Out

Executes one source line of a program. If the line is a method call, executes the methods and returns control to the caller.

F4

Run to Cursor

Runs the current project to the cursor's location in the file and stop program execution.

Ctrl-F8

Toggle Line Breakpoint

Adds a line breakpoint or removes the breakpoint at the cursor location in the program.

Ctrl-Shift-F8

New Breakpoint

Sets a new breakpoint at the specified line, exception, or method.

Ctrl-Shift-F7

New Watch

Adds the specified variable to watch.

Ctrl-F9

Evaluate Expression

Opens the Evaluate Expression dialog box.

Ctrl-Alt-Up

Make Callee Current

Makes the method being called the current call. Only available when a call is selected in the Call Stack window.

Ctrl-Alt-Down

Make Caller Current

Makes the calling method the current call. Only available when a call is selected in the Call Stack window.


Table 2-10 Profile Menu

Keys Command Action

Alt-F2

Profile Project

Profiles the main project or the currently selected project if no main project is set.

Ctrl-Shift-F2

Rerun Profiling Session

Enables you to start a new profiling session that uses the settings from the previous profiling session. The shortcut for this action is active only when no profiling session is in progress.

Alt-Shift-F2

Modify Profiling Session

Opens the Select Profiling Task when a profiling session is in progress. You can modify the profiling task or criteria without stopping the application that you are profiling. The shortcut invokes this action only when no profiling session is in progress.

Ctrl-F2

Take Snapshot of Collected Results

Takes a snapshot of the collected profiling results and displays the results in a new window.


Table 2-11 Tools Menu

Keys Command Action

Ctrl-Shift-J

Insert Internationalized String

Enables you to add an internationalization string as you create the source.


Table 2-12 Window Menu

Keys Command Action

Ctrl-0

Editor

Switches to the Source Editor.

Ctrl-1/Ctrl-Shift-1

Projects

Opens the Projects window.

Ctrl-2/Ctrl-Shift-2

Files

Opens the Files window.

Ctrl-3/Ctrl-Shift-3

Favorites

Opens the Favorites window.

Ctrl-4

Output Window

Opens the Output window.

Ctrl-5

Services

Opens the Services window.

Ctrl-Shift-6

Tasks

Opens the Tasks window.

Ctrl-6

Action Items

Opens the Action Items window.

Ctrl-7

Navigator

Opens the Navigator.

Alt-Shift-1

Debugging > Variables

Opens the Variables debugger window.

Alt-Shift-2

Debugging > Watches

Opens the Watches debugger window.

Alt-Shift-3

Debugging > Call Stack

Opens the Call Stack debugger window.

Alt-Shift-4

Debugging > Loaded Classes

Opens the Loaded Classes debugger window.

Alt-Shift-5

Debugging > Breakpoints

Opens the Breakpoints debugger window.

Alt-Shift-6

Debugging > Sessions

Opens the Sessions debugger window.

Alt-Shift-7

Debugging > Threads

Opens the Threads debugger window.

Alt-Shift-8

Debugging > Sources

Opens the Sources debugger window.

Ctrl-W

Close Window

Closes the current tab in the current window. If the window has no tabs, the whole window is closed.

Shift-Escape

Maximize Window

Maximizes the Source Editor or the present window.

Alt-Shift-D

Configure Window > Dock

Pins a detached window to the IDE.

Ctrl-Shift-W

Close All Documents

Closes all open documents in the Source Editor.

Shift-F4

Documents

Opens the Documents dialog box, in which you can save and close groups of open documents.

Ctrl-Tab (Ctrl-')

Switch to Recent Window

Toggles through the open windows in the order that they were last used. The dialog box displays all open windows and each of the open documents in the Source Editor.


Table 2-13 Help Menu

Keys Command Action

F1

Help

Displays the help topic for the current UI element in the JavaHelp viewer.

Shift-F1

Javadoc Index Search

Lets you search the Javadoc index.


2.6 Understanding the Source Editor Features

The Source Editor is a full-featured text editor that is integrated with the GUI Builder, the compiler, the debugger, and other parts of the IDE. You can generally open the Source Editor by double-clicking a node in the Projects window, Files window, or Navigator window.

The top of the Source Editor has a tab for each open document. Each tab shows the name of the document. The name of the document is displayed in bold if the document has been modified and has not been saved. You can right-click the tab to open a popup menu that lists commands that can be invoked on the tab.

If multiple files are open, you can split the Source Editor view by clicking and dragging the tab. As you drag to different parts of the editing area, you see a red outline that shows you the location of the new window. When one of these boxes appears, you can drop the document and split the pane. You must close the split file if you want the editor to return to its unsplit state.

2.6.1 How to Use the Toolbar

The editor toolbar is at the top of the Source Editor window. The toolbar has buttons for various navigating and editing shortcuts, which vary according to the type of file you are editing. Hold the cursor over a button to display a description of the command.

How to toggle the editor toolbar:

  • Choose View > Show Editor Toolbar to hide or display the editor toolbar.

The following table provides descriptions of icons that are used in the source editor toolbar.

Table 2-14 Icons in Source Editor Toolbar

Icon Description

Source/History

Toggle between source code and local history views. Local history includes diffs between all save points.

Last Edit icon Last Edit (Ctrl+Q)

Moves to the last edit you made.

Back icon Back (Alt+LEFT)

Moves back to previously opened document.

Forward icon Forward (Alt+RIGHT)

Moves forward to next opened document.

Find Selection icon Find Selection (Ctrl+F3)

Finds the item in which the cursor is currently inserted.

Find Previous Occurrence Find Previous Occurrence (Shift+F3)

Moves the insertion point to the previous found occurrence of the text that you previously searched for.

Find Next Occurrence icon Find Next Occurrence (F3)

Moves the insertion point to the next found occurrence of the text that you previously searched for.

Toggle Highlight Search icon Toggle Highlight Search (Alt+Shift+H)

Turns off or turns on the highlighting of search text.

Toggle Rectangular Selection icon Toggle Rectangular Selection (Ctrl+Shift+R)

Turns off or turns on the rectangular block selection.

Previous Bookmark Previous Bookmark

Moves the insertion point to the previous bookmark in the file.

Next Bookmark Next Bookmark

Moves the insertion point to the next bookmark in the file.

Toggle Bookmark icon Toggle Bookmark

Inserts a bookmark on the current line or removes a bookmark on the current line.

Shift Line Left icon Shift Line Left (Alt+Shift+LEFT)

Reduces the indentation by one tab stop.

Shift Line Right icon Shift Line Right (Alt+Shift+RIGHT)

Increases the indentation by one tab stop.

Start Macro Recording Start Macro Recording

Starts recording a macro containing keystrokes and cursor movements.

Stop Macro Recording Stop Macro Recording

Stops macro recording.

Check XMLCheck XML (Alt+F9)

Check XML document is well-formed.

Validate XML iconValidate XML (Alt+Shift+F9)

Validate XML document against DTD or schema specified in document.

Run XSL icon Run XSL

Run XSL transformation on open XSLT document.

Next Matching icon Next Matching

Completes the word you are typing to match the next word in the file that matches the word you are typing.

Previous Matching Previous Matching

Completes the word you are typing to match the closest previous word in the file that matches the word you are typing.

Comment icon Comment

Comments out the selected lines

Uncomment icon Uncomment

Removes the comment marks from the selected lines


2.6.2 How to Use the Left Margin

The left margin displays annotation glyphs that indicate line status, such as breakpoints, the program counter, or build errors. You can right-click the left margin to display a pop-up menu with a list of commands and options.

If you click the left margin of a Java file, a breakpoint is set on the corresponding line. You can click the left margin of a line to remove a breakpoint.

For more information about setting breakpoints and other glyphs used by the debugger, see Chapter 9, "Managing Breakpoints."

The following table shows some of the annotation glyphs that can appear in the left margin of the Source Editor.

Table 2-15 Table of Common Editor Glyphs and Descriptions

Glyph Description

Error glyph

The line contains an error. You can place the mouse pointer over the glyph to display a tooltip with information on the error.

Override glyph

The line contains a method that overrides a method from another class. Place your mouse pointer over the glyph to display a tooltip with name of the overridden method's class. This glyph only applies to Java classes.

Implement glyph

The line contains a method that implements a method from an interface or an abstract class. Place your mouse pointer over the glyph to display a tooltip with name of the implemented method's class. This glyph only applies to Java classes.

Bookmark glyph

The line is bookmarked. You can cycle forward and backward through your Source Editor bookmarks by pressing Ctrl-Shift-Period/Comma. You can add or remove a bookmark by pressing Ctrl-Shift-M.

Breakpoint glyph

The line contains a debugging line breakpoint. You can remove the breakpoint by clicking the glyph. You can set another breakpoint by clicking in the left margin next to the line where you want the breakpoint to appear.

Multiple annotations glyph

The line contains multiple annotation glyphs. Click the glyph to cycle through the annotations.


2.6.3 How to Use the Error Stripe

The error stripe is the strip to the right of the right scroll bar and contains marks for various things in your file, such as errors, bookmarks, and comments for the To Do list. The error stripe represents the whole file, not just the lines currently displayed. You can immediately identify whether your file has any errors without having to scroll through the entire file. You can double-click a mark in the error stripe to jump to the line that the mark refers to.

2.6.4 How to Use the Status Line

The Source Editor status line is beneath the horizontal scroll bar. The first area of the status line shows the current line number and row number in the form line:row. The second area of the status line indicates the insertion mode (INS or OVR). The text area on the right is used for status messages.

2.6.5 How to Use Syntax Coloring

Source code displayed in the Source Editor is syntactically colored. For example, all Java keywords are shown in blue and all Java comments in light gray. Guarded blocks of Java code generated by the GUI Builder have a light blue background and cannot be edited.

2.6.6 How to Use Insert Mode and Overwrite Mode

When the Source Editor is in insert mode, the default insertion point is a vertical bar, and text that you type is inserted. In overwrite mode, the default insertion point is a solid block, and text that you type replaces the existing text.

Use the Insert key to toggle between the two modes.

Whenever the insertion point in the Source Editor is located immediately after a brace, bracket, or parenthesis, the matching brace, bracket, or parenthesis is highlighted.

If the Source Editor beeps when you try to enter new text, the file is a read-only file.

2.6.7 How to Set Editor Options

You can set options for the source editor in the Options window. The Editor category in the Options window contains tabs where you can set options for editor features, including code completion, formatting and folding.

You can set options for the colors of text and background colors in the Fonts and Colors category. The IDE includes several fonts and colors settings that are saved as profiles. You can choose to use one of the default settings profiles or create a custom profile that saves your font and color preferences.

How to set global editor options:

  1. Choose Tools > Options from the main menu.

  2. Click the Editor category and then click a tab to edit the settings for that feature.

How to specify global fonts and colors in the editor:

  1. Choose Tools > Options from the main menu.

  2. Click the Fonts & Colors category and then click a tab to edit the settings for that feature.

  3. Select an item in the Category or Highlighting pane and then modify the color or other properties for that element in the right pane of the Options window.

How to enable a default profile:

  1. Choose Tools > Options from the main menu.

  2. Click the Fonts & Colors category.

  3. Select a profile from the Profiles drop-down list.

When you select a profile you can see an example of the new settings in the Preview pane.

How to create a custom profile for fonts and colors

  1. Choose Tools > Options from the main menu.

  2. Click the Fonts & Colors category.

  3. Select a profile from the Profile drop-down list to use as a base for the custom profile.

  4. Click Duplicate and type a name for the new profile.

  5. Modify the font and color options as desired.

    When you modify the new profile you can see an example of the new settings in the Preview pane.

  6. Click Apply in the Options window.

How to set formatting options for a project:

  1. Right-click the project node in the Projects window and choose Properties.

  2. Select the Formatting category in the Project Properties window.

  3. Select Use project specific options in the Formatting panel and specify the options.

2.6.8 How to Highlight Occurrences in the Editor

By default the editor highlights the occurrences of various code symbols and keywords when the insert cursor is located in one of the occurrences. You can disable the highlighting completely or limit the highlighting to specific elements.

How to select types of occurrences to highlight in the editor:

  1. Choose Tools > Options from the main menu, and then click the Highlighting tab in the Editor category.

  2. Select a language in the drop-down list.

  3. Deselect the types of elements that you do not want to be highlighted.

You can disable the highlighting of all types of elements for the specified language by deselecting Mark Occurrences Of Symbol Under Caret.

2.6.9 How to Record Macros

You can use macros in the source editor that can generate common source code snippets or perform common editor tasks. After you record a macro you can assign a keyboard shortcut to run the macro on the current file.

How to record a macro:

  1. Click the Start Macro Recording icon in the toolbar of the source editor.

  2. Perform the tasks or type the code that you want to record.

  3. Click the Stop Macro Recording icon in the toolbar.

    When you click Stop Macro Recording the IDE opens the New Macro Dialog.

  4. Type a name for the macro. Click OK.

  5. Select the new macro in the Editor Macros dialog box and click Set Shortcut.

  6. Type a shortcut in the Add Shortcut dialog box. Click OK.

  7. Click OK in the Editor Macros dialog box.

    The new macro will not be saved if you click Cancel in the Editor Macros dialog box.

To view or modify your saved macros, choose Tools > Options in the main menu and click the Macros tab in the Editor category.

2.6.10 How to Modify Source Editor Code Templates

Code Templates are abbreviations that you type into the code and that the editor expands into code blocks. The templates can include placeholder values. After you expand a code template, you go through the expanded block and replace the placeholder values.

The IDE includes default code templates for various languages. You can use the Options window to create, remove and modify code templates.

To modify an existing code template:

  1. Choose Tools > Options from the main menu, and then click Code Templates tab in the Editor category.

  2. Select a language from the drop-down list to see the code templates available for that language.

  3. Select a code template from the list.

  4. Type in the Expanded Text tab to modify the expanded code that the template produces.

  5. Type in the Description tab to modify the description of the code template. Click OK in the Options window.

To remove an existing code template:

  1. Choose Tools > Options from the main menu, and then click the Editor category.

  2. Select a language from the drop-down list to see the code templates available for that language.

  3. Select a code template from the list.

  4. Click Remove.

To create a code template:

  1. Choose Tools > Options from the main menu, and then click the Editor category.

  2. Select a language from the drop-down list.

  3. Click New.

  4. Type an abbreviation for the new code template in the dialog box.

  5. Type the expanded code in the Expanded Text tab.

  6. Type a description for the code in the Description tab.

  7. Click OK in the Options window.

2.6.11 Using General Editor Shortcuts

The IDE includes keyboard shortcuts that you can use to activate many Source Editor operations.

In the following table, multikey shortcuts are written in the following format: Ctrl-U, T. To use this shortcut, hold down the Ctrl key and press U, then release both keys and press T.

Table 2-16 Scrolling and Selecting

Keys Action

Ctrl-down arrow

Scrolls the window up without moving the insertion point.

Ctrl-up arrow

Scrolls the window down without moving the insertion point.

Ctrl-[

Moves the insertion point to the highlighted matching bracket. This shortcut only works when the insertion point is immediately after the opening or closing bracket.

Ctrl-Shift-[

Selects the block between a pair of brackets. This shortcut only works when the insertion point is immediately after either the opening or closing bracket.

Ctrl-G

Jumps to any specified line.

Ctrl-A

Selects all text in the file.


Table 2-17 Modifying Text

Keys Action

INSERT

Switches between insert text and overwrite text mode.

Ctrl-Shift-J

Opens the Internationalize dialog box that you can use to insert an internationalized string at the insertion point.

Ctrl-U, U

Makes the selected characters or the character to the right of the insertion point uppercase.

Ctrl-U, L

Makes the selected characters or the character to the right of the insertion point lowercase.

Ctrl-U, S

Reverses the case of the selected characters or the character to the right of the insertion point.


Table 2-18 Code Folding

Keys Action

Ctrl-Minus (-)

Collapses the block of code the insertion point is on.

Ctrl-Plus (+)

Expands the block of code the insertion point is next to.

Ctrl-Shift-Minus (-)

Collapses all blocks of code.

Ctrl-Shift-Plus (+)

Expands all blocks of code.


Table 2-19 Cutting, Copying, Pasting, and Deleting Text

Keys Action

Ctrl-Z

(Undo) Reverses (one at a time) a series of editor actions, except Save.

Ctrl-Y

(Redo) Reverses (one at a time) a series of Undo commands.

Ctrl-X

(Cut) Deletes the current selection and places it into the clipboard.

Shift-Delete

(Cut) Deletes the current selection and places it into the clipboard.

Ctrl-C

(Copy) Copies the current selection to the clipboard.

Ctrl-Insert

(Copy) Copies the current selection to the clipboard.

Ctrl-V

(Paste) Pastes the contents of the clipboard at the insert point.

Delete

(Delete) Deletes the current selection.

Ctrl-E

Deletes the current line.

Ctrl-U

Deletes text in the following sequence:

  • text preceding insertion point on same line

  • indentation on same line

  • line break

  • text on previous line

Ctrl-Backspace

Removes the text in the current word preceding the insertion point.


Table 2-20 Searching for Text

Keys Action

Ctrl-F3

Searches for the word the insertion point is on and highlights all occurrences of that word.

F3

Selects the next occurrence of the word in your current search.

Shift-F3

Selects the previous occurrence of the word in your current search.

Alt-Shift-H

Switches highlighting of search results on or off.

Ctrl-F

Opens the Find dialog box.

Ctrl-H

Opens the Find and Replace dialog box.


Table 2-21 Setting Tabs

Keys Action

Tab

Shifts all text to right of insertion point to the right.

Alt-Shift-Right

Shifts text in line containing the insertion point to the right.

Alt-Shift-Left

Shifts text in line containing the insertion point to the left.


Table 2-22 Using Bookmarks

Keys Action

Ctrl-Shift-M

Sets or unsets a bookmark at current line.

Ctrl-Shift-Period/Comma

Goes to next/previous bookmark.


2.7 Setting Startup Parameters

You can pass startup parameters to the IDE launcher using the IDE-HOME/etc/netbeans.conf file or on the command line. The launcher reads the netbeans.conf file prior to parsing the command-line options, including any parameters you have added. The netbeans.conf file contains details on some of the available startup switches, including switches to modify the heap size.

Table 2-23 Description of Common Switches

Switch Description

--help (or -h)

Prints descriptions of common startup parameters.

--jdkhome jdk-home-dir

Uses the specified version of the JDK instead of the default JDK. By default on Microsoft Windows systems, the IDE's launcher looks into the registry and uses the latest JDK available.

You should back up your user directory before you upgrade the JDK that the IDE uses. If you later need to revert to the previous JDK, switch to the backed up user directory to ensure that you do not lose any settings.

To switch the IDE's user directory, use the --userdir switch that is detailed below.

--cp:p additional-classpath

Prefixes the specified class path to the IDE's class path.

--cp:a additional-classpath

Appends the specified class path to the IDE's class path.

--open file

Opens the file in the Source Editor.

--open file:line number

Opens the file in the Source Editor at the specified line.

--laf UI-class-name

Selects the given class as the IDE's look and feel. The following are two examples of look and feel classes.

  • com.sun.java.swing.plaf.motif.MotifLookAndFeel

  • javax.swing.plaf.metal.MetalLookAndFeel

--fontsize size

Sets the font size, expressed in points, in the IDE's user interface. If this option is not used, the font size is 11 points.

--locale language[:country[:variant]]

Activates the specified locale.

--userdir userdir

Explicitly specifies the user directory, which is the location where user settings are stored.

If this option is not used in UNIX environments, the user directory is set in the HOME directory by default. If this option is not set on Microsoft Windows systems, the user directory is the one you specified when you first launched the IDE.

You can determine the current user directory in the About dialog box.

--cachedirpath

Specifies the directory to store the user cache.

-Jjvm-flags

Passes the specified flags directly to the JVM software.

-J-Dsun.java2d.noddraw=true

Prevents the use of DirectX for rendering. This switch might prevent problems that occur on some Microsoft Windows systems with faulty graphics cards.


Note:

When adding startup switches, you can break options into multiple lines.

For information about your userdir and cachedir, see the following document.

http://wiki.netbeans.org/FaqWhatIsUserdir

For information about performance-related startup switches, see the following document.

http://performance.netbeans.org/howto/jvmswitches/

For information about modifying the JVM heap size, see the following FAQ on the NetBeans wiki.

http://wiki.netbeans.org/FaqSettingHeapSize

2.8 Setting Fonts and Colors for IDE Windows

You can customize the font and color properties that are used in various windows in the IDE. Font properties include the font family, style, variant, weight, and size. Color properties include the color of text, the background color of text, and the color of borders.

2.8.1 How to Set Fonts and Colors for the Help Viewer

You can customize the font and color properties that are used to display the pages in the help viewer. Font properties include the font family, style, variant, weight, and size. Color properties include the color of text, the background color of text, and the color of borders.

To set fonts and colors for displaying help pages:

  1. From the main window, choose File > Open File.

  2. In the Open dialog box, navigate to IDE-install-directoryide/docs/org/netbeans/modules/usersguide and open the file ide.css.

    The ide.css file is the style sheet that describes how to present the fonts and colors in the help pages.

  3. Edit ide.css to your preferences.

  4. Choose File > Save.

  5. Open the help viewer and verify your changes.

2.8.2 How to Set Fonts and Colors for the Output Window

You can customize the font and color properties that are used to display the pages in the help viewer. Font properties include the font family, style, variant, weight, and size. Color properties include the color of text, the background color of text, and the color of borders.

To set fonts and colors for the Output window:

  1. Choose Tools > Options from the main menu.

  2. Click the Output tab in the Miscellaneous category.

2.8.3 How to Set Fonts and Colors for the Terminal Window

You can customize the font and color properties that are used to display the pages in the help viewer. Font properties include the font family, style, variant, weight, and size. Color properties include the color of text, the background color of text, and the color of borders.

To set fonts and colors for the Terminal:

  1. Choose Tools > Options from the main menu.

  2. Click the Terminal tab in the Miscellaneous category.

2.9 Managing Plugins in the IDE

The IDE's Plugins manager enables you to update and manage your IDE's plugins dynamically. You can minimize startup time and save memory by deactivating the plugins that you do not need. Deactivated plugins are not deleted from your installation directory, but are simply ignored by the IDE. You can re-activate them at any time.

You can also choose to uninstall plugins from the IDE. Uninstalled plugins are removed from your installation directory. To use an uninstalled plugins, you need to install it again.

You use the Plugins manager to connect to the update centers to check if there are new plugins or new versions of already installed plugins available. If new or updated plugins are available, you can select, download, and install them using the Plugins manager.

A plugin generally consists of a group of dependent modules. Some IDE plugins are grouped together and referred to as a Feature. Each Feature generally corresponds to a technology and can contain a number of plugins that support that technology. When you activate or deactivate a Feature, the IDE activates or deactivates the corresponding plugins.

When you update a plugin, the update usually consists of updating one or more of the modules that make up the plugin. Some plugins may be dependent on modules in other plugins in order for the functionality to be implemented. The Plugins manager warns you when this is the case. Deactivating a plugin usually consists of deactivating the individual modules that make up the plugin.

2.9.1 How to Update the IDE from the Update Center

When you use the Plugins manager to update the IDE, the IDE checks the registered update centers to see if there are new plugins or new versions of already installed plugins available. If new or updated plugins are available, you can select, download, and install the plugins using the Plugins manager. You can set the frequency that the IDE checks for updates in the Settings tab of the Plugins manager.

Alternatively, you can choose Help > Check For Updates from the main menu to open the Plugin Installer. The Plugin Installer will check for updates of installed in plugins. If updates are available, you can step through the installer to install the updates.

In addition to the default IDE Update Center, you can choose from several update centers that offer different types of plugins, such as experimental new plugins or old plugins that are no longer in regular distribution.

To update installed plugins from the Update Center:

  1. Choose Tools > Plugins from the main menu to open the Plugins manager.

  2. Click the Updates tab to display available updates of installed plugins.

  3. In the left pane, select the plugins you wish to update and click Update.

  4. Complete the pages in the installer to download and install the update.

The left pane of the Updates tab displays the installed plugins which have updates available from the update centers. By default, the IDE regularly checks the registered update centers for available updates of installed plugins. If no plugins are displayed in the left pane, it means that no updates were available the last time the IDE checked the update center.

To add new plugins from the Update Center:

  1. Choose Tools > Plugins from the main menu to open the Plugins manager.

  2. Click the Available Plugins tab to display plugins that are available but not installed.

  3. In the left pane, select the plugins you wish to add and click Install.

  4. Complete the pages in the installer to download and install the plugin.

Note:

Some plugins may require you to restart the IDE to complete the update process or to activate or deactivate them.

2.9.2 How to Install Downloaded Plugins

If you have already downloaded a plugin's .nbm file, you can manually install it without having to connect to an update center.

To install a downloaded plugin:

  1. Choose Tools > Plugins from the main menu and select the Downloaded tab.

  2. Click Add Plugins and browse to the location of the downloaded .nbm file. Select the file and click Open.

  3. Repeat the previous step for each plugin that you wish to add.

  4. Click Install and complete the pages of the installer to install the plugin.

If the plugin that you have selected in the file chooser does not appear in the Downloaded tab of the Plugins manager, you probably have the same or a newer version of that plugin already installed. You can check the Installed tab to verify that the plugin is installed and activated.

2.9.3 How to Activate and Deactivate Plugins

The IDE enables you to deactivate installed plugins that you do not need to minimize startup time and save memory. Deactivated plugins are not deleted from your installation directory, but are simply ignored by the IDE. You can re-activate them at any time. You do not need to download the plugins again.

To activate or deactivate an installed plugin:

  1. Choose Tools > Plugins from the main menu and then click the Installed tab in the Plugins manager.

  2. In the left pane, select the plugin you wish to activate or deactivate.

    The icon in the Active column indicates the status of the plugin.

  3. Click Activate or Deactivate to activate or deactivate the plugin.

    The icon for the plugin in the left pane reflects the new status of the plugin.

  4. Click Close to exit the Plugins manager.

If you want to completely remove a plugin from your local system, select the checkbox for the plugin in the left pane and then click Uninstall.

The following table defines the icons used in the Installed tab of the Plugins manager to indicate the status of plugins.

Table 2-24 Plugin Status Icons

Icon Description

Plugin is installed and activavted

The plugin is installed and activated.

The IDE must be restarted to deactivate the plugin

The plugin will be fully deactivated after you restart the IDE.

Plugin is not activated

The plugin is installed but deactivated.


2.9.4 How to Globally Install Plugins

If you are using a multi-user installation of the IDE, you can install a plugin globally so that the plugin is available to all users. When you install or update a plugin using the Plugins manager, the IDE places the plugin JAR and docs in your user directory. The IDE places JAR and docs for globally installed plugins in your installation directory instead of an individual user directory.

To globally install a plugin:

  1. Choose Tools > Plugins to open the Plugins manager.

  2. Click the Settings tab and then select Force install into shared directories in the Plugin Install Location drop-down list.

  3. Click the Available Plugins tab, select the Install checkbox for the plugin and click Install.

    You can also install manually downloaded plugins in the Downloaded tab.

  4. Follow the wizard instructions to complete the installation of the plugin.

  5. Restart the IDE to activate the new plugin, if necessary.

To install a plugin globally, you must have write access for the IDE installation directory.

2.9.5 How to Add an Update Center

The IDE's Plugins manager enables you to update your IDE's installed plugins from registered update centers. You can specify the update centers you want the IDE to check and how often the IDE checks the update centers.

You can manage the registered update centers in the Settings tab of the Plugins manager. In addition to the default IDE Update center, you can add other update centers that offer different types of plugins, such as experimental new plugins or old plugins that are no longer in regular distribution.

To add an update center:

  1. Choose Tools > Plugins from the main menu to open the Plugins manager.

  2. Click the Settings tab to display the registered update centers.

  3. Click Add to open the Update Center Customizer dialog box.

  4. Type the name of the update center and the URL and click OK.

In the Settings tab of the Plugins manager you can also do the following:

  • Deactivate an update center by deselecting the Active checkbox for the update center you wish to deactivate. You can reactivate the update center later if you wish.

  • Edit the details of an update center by selecting the update center in the left pane and clicking Edit in the right pane.

  • Remove an update center by selecting the update center in the left pane and clicking Remove in the right pane.

2.9.6 How to Schedule Update Checks

By default, the IDE periodically checks the update centers for new updates. You can set the interval or specify that the IDE should not automatically check for updates.

To schedule update checks:

  1. In the Settings tab of the Plugins manager, choose a frequency from the Check Interval drop-down list. Choose Never if you do not want the IDE to automatically check for updates.

  2. Click Proxy Settings if you need to set any proxy settings needed to enable the IDE to access the update centers.

2.10 Displaying IDE Help in a Web Browser

The online help is designed to be viewed in the JavaHelp viewer, which is integrated into the IDE. If you prefer, you can view the online help in the IDE's web browser or in another HTML browser.

2.10.1 How to Extract IDE Help from a JAR File

The online help is divided into several help sets. Most help sets are packaged in a JAR file, while a few help sets are packaged in a zip file. Help sets are typically stored in the ide/modules/docs directory in your installation directory.

To extract the online help from a JAR file:

  1. In a command window, change to the install-directory/ide/modules/docs directory and list the files in that directory.

  2. Use the jar command-line utility to unpack the JAR file in which you are interested. On Microsoft Windows systems and UNIX systems, the command is as follows:

    jar xf jar-file

    For jar-file, use the file name of the JAR file from which you want to extract files.

    The Jar tool makes copies of the files and writes them to the current directory. The directory structure is reproduced according to the package structure in the archive.

2.10.2 How to View IDE Help in a Web Browser

To view the online help in a web browser:

  1. From the IDE main window, choose View > Web Browser.

  2. In the web browser use the File Browser and navigate to the files you just extracted.

2.11 Internationalizing Source Code

The IDE's internationalization tools let you easily insert internationalization strings while you write your code as well as internationalize files that are already written. You can also check resource bundles to make sure each key referenced by your code exists.

When you internationalize existing source files, the IDE searches for every customizable occurrence of a quoted text string. If you decide to internationalize the string, the IDE replaces it with a method call and adds the string to the appropriate resource bundle. You can select from several code formats for generating internationalized strings, or you can use your own custom format.

2.11.1 How to Enable Automatic Internationalization

As you design a form in the GUI Builder, you can have the code generated as internationalized code.

To turn on automatic internationalization for a form:

  1. Open the form and make sure that the form appears in the Design view.

  2. In the Navigator window, select the root node for the form.

  3. In the Properties window, select the Automatic Internationalization checkbox.

2.11.2 How to Internationalize a Single File

The Internationalize dialog box enables you to replace hard-coded strings in a single file with internationalized strings. If you need to internationalize several Java sources into one or more resource bundles, use the Internationalization wizard.

To internationalize source code:

  1. In the Files or Projects window, right-click the class file you want to internationalize and choose Tools > Internationalization > Internationalize.

    The Internationalize dialog box opens enabling you to edit each string in the file consecutively.

    • If a resource bundle already exists for the file, the bundle properties file in which the strings are saved is displayed in the Bundle Name field. The Replace String field also displays a preview of the internationalized string.

    • If no resource bundle exists for the file, the Bundle Name and Replace String fields are empty. You can click the ellipsis (...) button to specify a properties file or create a new one in which to save internationalized strings.

  2. If you want to change the method used to generate the localized string, click Format.

  3. If you want to add arguments to the method call, click Arguments. You can only add arguments to the method call if you use the java.text.MessageFormat or org.openide.util.NbBundle.getMessage formats.

  4. Check that the key and value are correct. By default, the Internationalize dialog box gives the key the same name as the string being replaced.

  5. Click Replace to generate the internationalized string.

    The next string to be internationalized is then displayed in the Value text field.

  6. Click Skip to ignore any strings you do not want to internationalize.

    The IDE automatically dismisses the dialog box once the last string has been replaced.

To get information about the highlighted string in the Source Editor, click Info to see the name of the component containing the string and the property that the string is associated with.

2.11.3 How to Use the Internationalization Wizard

The Internationalization wizard enables you to replace hard-coded strings with internationalized strings in multiple files. If you are localizing the source into more than one language, the Internationalization wizard also lets you specify the localized string for multiple locales.

To automatically internationalize strings in multiple source files:

  1. Choose Tools > Internationalization > Internationalization Wizard from the main window.

  2. Click Add Source(s) to add one or more source files to internationalize. Click Next to proceed.

  3. Click Select All if you want a single resource bundle to contain the key and value pairs for all the listed sources. To select a resource bundle for specific source files, select the desired sources and click Select Resource. In the Select Resource dialog box, select the desired .properties file or create a new file. Click Next to proceed.

    To modify key and value pairs:

    1. From the Source drop-down list, select the source file in which you want to create the variable.

    2. Select the Generate Field checkbox and set the variable's modifiers.

    3. Type the name of the identifier in the Identifier text field.

    4. The Init String field gives you a preview of the code that the variable will use to reference the resource bundle. To change this code, click Format and select the desired code format from the Init Code Format Editor.

    5. Click Next to generate the field.

  4. In the Modify Found Strings pane, set the key name and localized values for each of the strings you want to internationalize by entering a new value in the appropriate column. Use the Source drop-down list to switch between source files. Deselect the checkbox in the first column for any string you do not want to internationalize.

  5. To change the code format used to generate the internationalized string or add arguments to the method call, click the ellipsis button (...) at the end of the string's row.

  6. Click Finish to internationalize the strings for all of the selected source files.

2.11.4 How to Insert an Internationalized String Into Source Code

The Insert Internationalized String command enables you to add internationalization strings one at a time as you create the source.

To insert an internationalized string into your source code:

  1. In the Source Editor, put the insertion point at the location in the source file where you want to insert an internationalized string.

  2. Right-click the desired location and choose Tools > Internationalization > Insert Internationalized String from the pop-up menu, or use the keyboard shortcut (Ctrl-Shift-J).

    The Insert Internationalized String dialog box appears enabling you to edit each string in the file consecutively. To choose a different .properties file or create a new file, click the ellipsis (...) button.

  3. Click Format if you want to change the method used to generate the localized string.

  4. Click Arguments if you want to add arguments to the method call. You can only add arguments to the method call if you use the java.text.MessageFormat or org.openide.util.NbBundle.getMessage formats.

  5. Type in values for the Key and Value properties and click OK.

2.11.5 How to Internationalize a String With the GUI Builder

If you need to internationalize a GUI application, you can use the GUI Builder to replace a GUI component's hard-coded text with internationalized strings.

To insert an internationalized string with the GUI Builder:

  1. Open the desired file in the GUI Builder by double-clicking its node in the Files or Projects window.

  2. Select the appropriate GUI component in the Navigator window.

  3. In the Properties window, select the property that you want to internationalize (for example, the text property of jLabel).

  4. Select Resource Bundle from the drop-down list at the top of the dialog box.

    The property editor switches to resource bundle mode.

    If a resource bundle already exists for the source, the bundle properties file into which the internationalized strings will be saved is displayed in the Bundle Name field.

  5. If no .properties file is listed in the Bundle Name field, click the ellipsis (...) button next to the field to open the Select Resource Bundle dialog box. In the dialog box, specify an existing .properties file or create a new file. Click OK to return to the property editor.

  6. If you want to change the method used to generate the internationalized string, click the Format button.

  7. If you want to add arguments to the method call, click Arguments. You can add arguments to the method call only if you use the java.text.MessageFormat or org.openide.util.NbBundle.getMessage formats.

  8. Type in values for the Key and Value properties and click OK.

2.11.6 How to Test a Bundle for Internationalized Strings

You can check resource bundles for missing key and value pairs by using the Internationalization Test wizard. The wizard looks for all internationalized string keys (with a customizable meaning) in the source and checks for a corresponding key and value pair in the specified resource bundle. You can use the wizard to add any missing pairs.

To test a bundle for internationalized strings:

  1. Choose Tools > Internationalization > Internationalization Test Wizard.

  2. Click Add Source(s) and select one or more source files to test in the Select Sources dialog that appears. Click Next to proceed.

  3. Specify the resource bundles for the source files. Click Select All to check one resource bundle for all the listed sources. To select a specific resource bundle for one or more source files, select the desired sources and click Select Resource. Click Next to proceed.

    The wizard lists all of the internationalized strings with missing key and value pairs in the selected file. The wizard automatically suggests key names and values for the string.

  4. Use the Source drop-down list to switch between source files. Deselect the checkbox in the first column for any string you do not want to include in the resource bundle. Change the key name and value for any string by typing a new value in the appropriate column.

  5. Click Finish to add the missing key and value pairs to the resource bundle.

2.11.7 How to Add Arguments for Message Formats

The java.text.MessageFormat code format lets you use strings that are constructed dynamically at runtime. The dynamically added elements are stored in an array of objects, which is passed as a parameter to java.text.MessageFormat. You can use the Message Format Arguments dialog box to specify the values of these objects.

You can add arguments when you use the org.openide.util.NbBundle.getMessage format. This format is part of the NetBeans APIs and is used to build modules for the IDE. Consult the NetBeans API documentation for more information on this format.

To enter substitution parameters for a message format:

  1. In the Internationalize dialog box, click the Format button.

  2. Select the java.text.MessageFormat format or the org.openide.util.NbBundle.getMessage format from the Replace Code Format drop-down list. Then click OK.

  3. In the Internationalize dialog box, click the Arguments button.

  4. Click the Add button next to the Arguments text field.

    A series of parameters, beginning with 0, is added to the text field.

  5. Type a value for the parameter in the Code field.

  6. Use the Add and Remove buttons to add or remove message parameters. When you are done, click OK to close the dialog box.

  7. Finish entering values for the key and value fields as normal.

The arguments you supply are substituted for the {arguments} wild card in the following format:

java.text.MessageFormat(java.util.ResourceBundle.getBundle("bundle name").getString("key"), new Object[] {arg1, arg2, arg3})

2.12 Managing and Creating Projects

A NetBeans project is a group of source files and the settings with which you build, run, and debug those source files. In the IDE, all development has to take place within a project. For applications that involve large code bases, it is often advantageous to split your application source code into several projects.

2.12.1 How to Create a Project

NetBeans IDE provides wizards that enable you to create projects that are based on project templates. The IDE includes several project templates designed to support different types of development including general Java applications, Java web and enterprise applications, HTML5 applications and PHP applications.

To create a project:

  1. Choose File > New Project (Ctrl-Shift-N) from the main menu.

  2. Select the appropriate project template in the New Project wizard.

  3. Follow the steps in the remainder of the wizard.

For information on creating a Java Application Project, see Chapter 5, "Creating Java Projects."

For information on creating a Java Web Application Project, see Chapter 11, "Developing Web Applications."

For information on creating a Java EE Project, see Chapter 13, "Developing Enterprise Applications."

For information on creating an HTML5 Application Project, see Chapter 19, "Developing HTML5 Applications."

For information on creating a PHP Application Project, see Chapter 20, "Developing PHP Applications."

For information on creating a Java ME Application Project, see Chapter 21, "Developing Java ME Applications."

2.12.2 How to Work with Character Encodings for a Project

By default, newly-created projects in the IDE use UTF-8 character encoding. This encoding determines how the IDE interprets characters beyond the ASCII character set. The IDE displays and saves any new files you create using the encoding set by the project in which they reside. If you want to change encoding properties, the IDE provides you with the ability to do so manually.

The IDE implements the FileEncodingQuery (FEQ) layer model. FEQ is an interface for obtaining information about which encoding can be used for reading from/writing to a particular file. The layer model prioritizes encoding based on the following hierarchy:

  1. File FEQ. The encoding value declared within a file.

  2. Project FEQ. The value of the current global project encoding in a session.

  3. Fallback FEQ. The encoding of the locale in which the IDE is running.

Project created in NetBeans IDE 5.x and older did not implement the FEQ and will be opened using the fallback FEQ, the default locale set by your system's environment.

WARNING:

If you change the project encoding property on a project that already contains files that were created using a specific character encoding, there is a risk that compiling and running the project may not succeed. This is due to the fact that the programming compiler needs to be passed an encoding value, and there can only be one such value. Neither the IDE nor the programming language performs automatic encoding detection of files.

2.12.2.1 Changing the Character Encoding of a Project

When you change the encoding for a project, all new files are created using the new project encoding.

To change the character encoding for a project:

  1. Right-click the project node in the Projects window and choose Properties.

  2. In the left column under Categories, select Sources.

  3. In the Encoding drop-down list, select the character encoding that you want to be applied to the project. Click OK. The new encoding is applied to the project you are working in.

Note:

The new value that you set for project encoding is retained as the global project encoding value for new projects. Therefore, when you create a new project, the IDE uses the encoding value of the previously created project for the new project.

2.12.3 How to Organize Projects into Groups

You can create groupings of projects so that you can open and close several projects at once. In addition, each group can have a different main project. After you create a project group, that project group is available in the Project Group menu. When you select a project group from that menu, all other open projects are closed. If you want to close all open projects, choose File > Project Group > (none).

To create a project group:

  1. Choose File > Project Group > New Group from the main menu.

  2. Type the name of the new group in the Create New Group dialog box.

  3. Select the options for the group. Click Create Group.

    If you select the Automatically Save Project List option in the dialog box, projects that you open or close will automatically be added to or removed from the group.

To create a project group that contains a specific set of projects:

  1. Close any projects that you do not want to include in the group.

  2. Choose File > Project Group > Create New Group to open the Create New Group dialog box.

  3. Select Free Group.

  4. Select Use Currently Open Projects.

If you created a free group and deselected the Automatically Save Project List option when you created the group, you can perform the following steps to modify the contents of the group.

To modify the contents of a free group:

  1. Open the project group that you want to modify.

  2. Open any projects that you want to add to the group.

  3. Close any projects that you want to remove from the group.

  4. Choose File > Project Group > Properties of <group name>.

  5. Click Save Current Project List Now.

2.13 Working with Source Files in the IDE

The IDE provides tools that enable you to find, compare and move the files in your projects. You can also modify the properties of files and create file templates that you can use when you create files.

For information on editing Java source files, see Chapter 6, "Working with Java Code."

2.13.1 How to Find Files in Projects

You can use the Find in Projects command to locate the occurrences of specific text strings in files in your project. You can invoke the command from the popup menu in the Projects, Files and Favorites windows.

The results of the search are displayed in the Search Results window. The Search Results window displays a node for each file that contains the search string. When a file contains more than one occurrence of the string you can expand the node to view a list of each occurrence in the file. You can double-click an occurrence in the Search Results window to open the file in the editor at the line containing the search string.

To find a string in project files:

  1. Right-click the project or folder that you want to search and choose Find in the popup menu to open the Find in Projects dialog.

    Alternatively, you can select an element in the Projects, Files or Favorites windows and choose Edit > Find in the main menu.

  2. Type the search string in the Containing Text field.

  3. Specify any additional options that you want to apply to the search string.

  4. Specify the Scope of the search.

    By default the scope is the folder that you selected, but you can use the drop-down menu to modify the scope.

  5. Specify any File Name Patterns to limit the search to certain types of files.

  6. Click Find.

2.13.2 How to Specify Editor Formatting Options

You can specify how the source editor formats source code for various languages. You can specify formatting options globally to apply to all files in that language and also at the project level to specify the options for a specific project.

To specify global editor formatting options:

  1. Choose Tools > Options in the main menu to open the Options window.

  2. Click the Formatting tab in the Editor category.

  3. Select a language in the Languages drop-down list.

  4. Select a formatting category in the Category drop-down list.

  5. Specify the formatting options for the category. Click Apply in the Options window.

In addition to global settings, you can specify the editor formatting options at the project level that will only apply to the current project. You can also use the formatting options specified for an existing project and apply the options to the current project.

To specify editor formatting options for a project:

  1. Right-click the project node in the Projects window and choose Properties in the popup menu.

  2. Select Formatting in the Project Properties window.

  3. Select Use project-specific options.

  4. Select a language in the Languages drop-down list.

    Alternatively, click Load from other project to use the formatting options from an existing project.

  5. Select a formatting category in the Category drop-down list.

  6. Specify the formatting options for the category. Click OK.

2.13.3 How to Compare Two Files

You can use the diff viewer included in the IDE to compare source files. You can export a diff patch file directly from the diff viewer window.

The IDE can display diffs in either of two modes:

  • Graphical Diff Viewer. (Default) The graphical diff viewer displays the two files side by side and uses background highlight colors to display the differences between the two files. By default, changed lines are highlighted in blue, added lines are highlighted in green, and removed lines are highlighted in red.

  • Textual Diff Viewer. The textual diff viewer shows you the diff output in text so that you can copy and paste the output into a file or into an email.

You can use either the built-in diff engine or a command-line diff engine.

  • Built-in Diff Engine. (Default) The built-in diff engine enables you to compare two files without your needing a command-line diff executable installed on your system.

  • Command-line Diff Engine. Before you can use the command-line diff engine on a Microsoft Windows system, you must have a command-line diff executable (for example, from a Cygwin distribution) installed on your system. For the UNIX environment, there is a diff executable installed and available to you by default.

You can specify the diff engine in the Diff tab in the Miscellaneous category of the Options window. You can open the Diff tab by clicking Options in the diff viewer window or by choosing Tools > Options in the main menu.

To compare two files:

  1. Select two files in the IDE.

  2. Right-click and choose Tools > Diff from the pop-up menu to run the diff command.

    By default, the IDE opens the diff viewer window in graphical mode. You can click the Textual tab to view the diff in the textual diff viewer.

    You can click Options in the diff viewer window to open the Options window and select the diff engine that is used to find differences between files.

  3. Click Export in the diff viewer window to save the diff as a diff patch file.

2.13.4 How to Apply a Diff Patch to a File

A patch file enables you to modify or patch a file based on the differences between the two versions of the file. The differences between the versions are contained in a diff patch file. Patch files enable software developers who are not sharing a common repository to distribute and integrate changes that have been made to the code. The IDE enables you to create and apply patches that update copies of source files so that you do not have to incorporate the changes manually.

You can apply a patch to an individual file or a folder. Patches that are applied to folders use relative paths to the files within them. Folder patches must be applied on the same folder node that the patch was created on to ensure that the patch is applied properly. If you are uncertain to which file or folder the patch should be applied, you can find the context information in the patch file itself. Patch files generated by the IDE contain the context in which the patch was originally created in the first few lines of the file.

How to apply a patch file to a file:

  1. In the Projects window, right-click the file or folder to which you want to apply the diff patch and choose Tools > Apply Diff Patch in the popup menu.

  2. Locate the patch file in the file browser and click Patch.

When you apply the patch, the IDE applies the changes contained in the selected patch to the chosen file or folder and informs you that patch is successfully applied. In the Question dialog box, click Yes to view applied changes in the Diff Viewer or No to close the dialog box.

For details on applying patches to files that are under version control, see Section 3.3.16, "How to Create and Apply a Patch (Subversion)," and Section 3.5.17, "How to Create and Apply a Patch."

2.13.5 How to Access Files Outside of a Project

When developing applications, you must create a project for your source code and related files. If you need to access a file outside of your projects, you can do either of the following things:

  • Choose File > Open File in the main menu and navigate to the location of the file on your system.

  • Use the Favorites window to access the file.

To use the Favorites window:

  1. Choose Window > Favorites (Ctrl-3) in the main menu.

  2. Right-click in the Favorites window and choose Add to Favorites.

  3. Select the folder that you want to access and click OK.

Project-level commands, such as Run Project, are not available from the Favorites window. For such commands to be available, you need to have a project open in the Projects window.

2.13.6 How to Create a File Template

You can save a file as a template and add it to the types of templates available in the template chooser in the New File wizard.

To create a new template:

  1. In the Projects window, right-click the file you would like to turn into a template and choose Save As Template.

  2. In the Save As Template dialog box, select a category for the template and click OK.

To modify a an existing template:

  1. Choose Tools > Templates from the main menu.

  2. In the Template Manager, expand the appropriate category node and select the template.

  3. Click Open in Editor.

  4. In the Source Editor, make the desired changes to the template.

  5. Choose File > Save from the main menu.

In the Template Manager, you can click Duplicate to create new templates based on existing templates. You can create new folders and move templates between folders.

Note:

Templates are not project-specific. If you modify a template that is used by a wizard in the IDE the modified template will be used by that wizard for generating files in all projects.

2.13.7 How to Work with Unknown File Extensions

If you want to work with a file of a type that the IDE does not recognize, you can associate it with one of the file types that the IDE is familiar with.

To register a file extension as belonging to a specific file type:

  1. Choose Tools > Options from the main menu.

  2. Click the Files tab in the Miscellaneous category.

  3. Click New to open the Enter New File Extension dialog box.

  4. Enter the file extension that you want to register and click OK.

  5. In the Associated File Type (MIME) field, select the file and MIME type that you want to associate with your new file extension.

Note:

For some object types, such as Java objects, it is not possible to add an extension.

2.13.8 How to Specify Files to Ignore

If you have files that you do not want to be recognized by the IDE, you can configure the IDE to ignore these files.

Note:

If you set the IDE to ignore .class files, these files are not visible in the Files window under the build folder.

To specify files to be ignored:

  1. From the main window, choose Tools > Options and click Miscellaneous.

  2. Click Files and use the Ignored Files Pattern field to enter a POSIX-style regular expression to specify the files you want ignored.

Table 2-25 Table of useful characters for regular expressions

Character Description

|

Or.

^

Matches all file or directory names beginning with the subsequent characters.

$

Matches all file or directory names ending with the preceding characters.

\

Escape character. Necessary if you want to match to a period (.) or other special character.

.*

Wildcard.


2.13.9 How to Work with Character Encodings for Files

When creating a file for a project, the files are created using the specified project encoding. Some file types declare the encoding in the file (for example, HTML, JSP, and XML files). Therefore, when the IDE creates these files, it automatically includes character encoding declarations in the file template.

When determining the character encoding for a file, the IDE applies the FileEncodingQuery (FEQ) layer model. It first determines whether the encoding is declared in the file. If no encoding declaration can be found, the IDE presumes the file encoding is specified by the project's encoding property. If the project encoding is not specified (for example, imported or older projects), the IDE applies the encoding set by the environment in which it runs.

To change the encoding for a file (for example, HTMl, XML, or JSP files) you need to change the encoding and charset specified in the corresponding tag in the file. When an encoding is specified in a file, this setting overrides the encoding set in the project.

To manually change the character encoding for a file:

  1. Open the file in the Source editor.

  2. Modify the encoding and charset tags for the file, if available.

WARNING:

The IDE does not convert characters when the encoding of a file changes. If you manually change the encoding declaration within the file, and that encoding does not match the project encoding, you may encounter problems when compiling and running the project. The encoding tag affects how file contents are viewed internally - not only during runtime, but also during the design phase such as when you add content in the Source Editor.

WARNING:

Manually changing the character encoding declaration within a file changes how the IDE reads and displays that file. When you change the file encoding, the IDE does not convert the existing contents of the file to the new encoding. Care should be taken when changing the encoding of a file because the file may contain characters that cannot be saved or that may not display properly in the new encoding.

2.13.10 How to Specify Action Items

You can create a list of things that you need to resolve in your various projects and view the list as entries in the Action Items window. The list of action items can include compilation errors that are identified by the IDE, issues in an issue tracker and tasks that are identified by specific ToDo character patterns in project files. The IDE automatically scans your projects for action items and displays the items in the Action Items window.

Action items are created by some types of errors and by the occurrence of specific character patterns in the file. The list of action items can include the following types of items.

  • Compiler errors

  • Hudson tasks

  • Issues

  • Maven POM problems

  • TODO

  • Whitelist violations

By default, you can create action items by adding comments that contain the following patterns to a file.

  • TODO

  • XXX

  • FIXME

  • Javadoc comments that contain the @todo keyword (Java projects)

To create a custom pattern:

  • Choose Tools > Options from the main menu.

  • Click the Action Items tab in the Miscellaneous category.

  • Click Add and type the new pattern in the table. Click OK.

To edit or remove a pattern:

  • Choose Tools > Options from the main menu.

  • Click the Action Items tab in the Miscellaneous category.

  • Select a pattern in the table and click Edit to edit the selected pattern or Remove to delete the selected pattern. Click OK.

The IDE includes the following patterns as action items by default.

  • The pattern <<<<<<, which denotes merge conflicts in CVS and other version control systems

  • Lines where compiler errors are registered (Java projects)

To open the Action Items window:

  • Choose Window > Action Items.

You can double-click an entry in the Action Items window to jump to the line of the file where the action item needs to be resolved or open the issue in the IDE.

To create a filter for items in the Action Items window:

  1. Choose Window > Action Items to open the Action Items window.

  2. Click the Filter button in the Action Items window toolbar to open the Action Items Filter dialog box.

  3. Click New to create a new filter and type a name for the filter.

  4. Select the types of action items that you want to be displayed.

  5. (Optional) Click the Keywords tab and specify any additional criteria that needs to be met.

  6. Click OK.

To apply a filter to the list of action items, click the arrow on the Filter button and select a filter from the drop-down list.

2.13.11 How to Use Bookmarks in Files

Bookmarks enable you to quickly navigate to a specific line in a file. After you set a bookmark in a file you can use keyboard shortcuts to jump to the bookmark or between bookmarks in the file. You can view a list of your bookmarks in the Bookmarks window. When you double-click a bookmark in the Bookmarks window the IDE opens the file in the source editor at the line that contains the bookmark.

How to toggle a bookmark in a file:

  1. Place the insert cursor in the line in the file.

  2. Type Ctrl-Shift-M.

How to move between bookmarks in a file:

  1. Type Ctrl-Shift-Period or Ctrl-Shift-Comma to open the Bookmarks popup menu.

  2. Use the up and down arrows to navigate in the popup menu. Select a bookmark in the menu to open the file at the line containing the bookmark or select <Bookmarks> in the popup menu to open the Bookmarks window.

How to view a list of all bookmarks:

  1. Choose Windows > IDE Tools > Bookmarks from in the main menu.

2.14 Working with Resource Bundles

Resource bundles store selected characteristics of an object as key and value pairs in a set of .properties files. You can store a variety of characteristics in resource bundles, like localized strings used to internationalize your code or properties for an Ant script. The IDE displays resource bundles as properties object nodes ( Resource Bundle Properties onbject ) that contain nodes for each of its locales ( Resource Bundle Locale node ) and keys ( Resource Bundle Key node ).

When used for internationalizing source code, the IDE stores each locale's characteristics in a .properties file which is contained within the resource bundle. Each key corresponds to the name of a property and must be the same for each locale. The key value is the localized string displayed by the object at runtime and can vary for each locale.

The IDE also enables you to automate the process of internationalizing your source code. You can use the IDE's internationalization features to:

Note:

Though resource bundles and locales are both .properties files, the IDE displays resource bundles and the locales they contain using different icons in the Files window to avoid confusion.

2.14.1 How to Create and Delete Resource Bundles

The IDE enables you to manage resource bundles and the various key and locale pairs stored within them. When you use the New wizard to create a new properties file, the IDE automatically creates a .properties file for the default locale to which you can then add specific properties and additional locales.

A properties file is created with a .properties suffix. The Files window displays a properties object node ( Properties Object node ) for the resource bundle with one locale subnode (Resource Bundle Locale node ) for the default locale.

To create a resource bundle:

  1. Choose File > New to open the New wizard.

  2. Select the project in which you want to create the resource bundle.

  3. Expand the Other node in the Categories pane, select Properties File in the File Types pane, and click Next.

  4. Type the file name in the File Name field.

  5. Enter the location where you want to create the resource bundle. Click Finish.

To delete a resource bundle:

  1. Right-click the properties file in the Files window and choose Delete.

  2. In the verification dialog box, click Yes to remove the file.

2.14.2 How to Edit a Resource Bundle

There are two ways of editing the properties files contained in your resource bundles:

  • In the Source Editor as text files. The Source Editor displays one text file for each of the resource bundle's locales. Each locale file lists all the key and value pairs for that locale

  • In the Properties Editor, a special editor that is displayed inside the Source Editor. The Properties Editor displays key and value pairs for all locales of your resource bundle in table layout.

To edit a properties file in the Properties Editor:

  1. In the Files window, right-click the properties object node (Resource Bundle Properties Object node ) and choose Open.

    The Properties Editor is displayed showing all existing keys and their values for each locale.

  2. If you want to change a property's key, type the new name in the Key column.

  3. If you want to change a property's value for a locale, type the new value in the locale's Value column.

  4. If you want to add or remove keys, use the New Property and Remove Property keys.

To edit a property file as a text file:

  1. Right-click the properties object node and choose Edit to edit the default locale.

  2. If you want to edit a different locale, expand the properties object node, right-click the node for the locale you want to modify and choose Edit.

2.14.3 How to Add and Remove a Property

The IDE's Properties Editor enables you to manage the properties in all of the locales in your resource bundle. You can also add a property to or remove a property from only one locale.

To add a new property to all locales in a resource bundle:

  1. In the Files window, right-click the properties object node (Resource Bundle Properties Object node ) and choose Open.

    The Properties Editor is displayed showing all existing keys and their values for each locale.

  2. In the Properties Editor, click the New Property button.

  3. Enter a key and its default value for the new property.

    You can also add a comment along with the key and value. The comment is displayed when you click the value for that locale's key.

  4. Click OK.

    The property appears in the Properties Editor with the default value entered for each existing locale.

  5. If you want to set a different value for each locale, enter the new values in each locale's column.

  6. Choose File > Save to save the file.

To add a new property to a specific locale:

  1. In the Files window, expand the properties object node for the resource bundle that contains the locale.

  2. Right-click the node of the locale to which you want to add a property and choose Add Property.

  3. Enter a key and a value for the new property and click OK.

  4. Choose File > Save to save the file.

To remove a property from all locales in a resource bundle:

  1. In the Files window, right-click the properties object node and choose Open.

  2. In the Properties Editor, select the key for the property you want to remove.

  3. Click the Remove Property button.

  4. Click Yes in the verification dialog box.

To remove a property from a specific locale:

  1. In the Files window, right-click the properties object node and choose Delete.

  2. Click Yes in the verification dialog box

You can also delete an entire resource bundle and all of the .properties files contained within it by right-clicking its properties object node (Resource Bundle Properties Object node ) and choosing Delete.

2.14.4 How to Add and Remove a Locale

The New Locale dialog box provides an extensive list of predefined locales. It also lets you define your own locale by choosing the appropriate language code, country code, and language variant.

To add a locale:

  1. Right-click the properties object node (Resource Bundle Property Object node ) in the Files window and choose Add Locale.

  2. Select a language code, country code, and variant from the drop-down lists. You can also select from the list of predefined locales in the bottom of the dialog box.

  3. Click OK to add the locale.

To remove a locale:

  1. Expand the resource bundle's object node in the Files window.

  2. Right-click the locale and choose Delete.

You can also delete an entire resource bundle and all of the .properties files contained within it by right-clicking its properties object node (Resource Bundle Property Object node ) and choosing Delete.

2.14.5 How to Edit a Locale

The localized strings for each locale are stored in that locale's .properties file. You can modify a locale in the Source Editor as a text file or in the Properties Editor. You can also edit a specific locale using its customizer.

To edit a locale in the Properties Editor:

  1. Right-click the properties object node (Resource Bundle Property Object node ) in the Files window and choose Open.

    The Properties Editor is displayed showing all existing keys and their values for each locale.

  2. If you want to change a property's key, type the new name in the Key column.

  3. If you want to change a property's value for a locale, type the new value in the locale's Value column.

  4. If you want to add or remove keys, use the New Property and Remove Property keys.

To edit a locale as a text file in the Source Editor:

  1. Right-click the properties object node and choose Edit to edit the default locale.

  2. If you want to edit a different locale, expand the properties object node, right-click the node for the locale you want to modify and choose Edit.

To edit a locale using the customizer:

  1. Expand the properties object node in the Files window.

  2. Right-click the desired locale and choose Customize.

    The Locale customizer opens listing the locale name and each existing key.

  3. If you want to switch locales, click the ellipsis (...) button. This option is not available for the default locale.

  4. If you want to add a new property to the locale, click Add Key and enter the key name and value.

  5. If you want to remove a property from the locale, select the property and click Remove Key.

Note:

You cannot edit the existing values of properties with the customizer.

2.15 Working with Javadoc Documentation

2.15.1 How to Add Javadoc to a Project

You can make Javadoc documentation for a JAR file's class available in the IDE by associating that documentation with the JAR file.

When you add a required project to a project's classpath, the required project's Javadoc and sources are automatically added to the project as well.

When you create a Java class library for a single JAR file, you can simply add the JAR file to the project's classpath to make the associated Javadoc and source code available. If your Java library contains multiple JAR files, however, you must add the library itself to the classpath. Adding the library to the classpath also makes it easier to share the project with other developers.

To add Javadoc for a JAR file:

  1. Choose Tools > Libraries from the main menu.

  2. In the left pane of the Ant Library Manager, select the project library within which the JAR file you want to add Javadoc documentation to is located.

    Note:

    Only libraries already registered with the IDE are listed in the Ant Library Manager's Class Libraries list.

  3. If the JAR file for which you want to add Javadoc documentation has not already been added to a registered library, create a new empty library using the New Library button. Next, in the Classpath tab click Add JAR/Folder and specify the location of the JAR file containing the compiled class files.

    Note:

    You can also associate the Javadoc with a JAR file using the project's Project Properties window. However, doing so creates the association only for that project. Open the Project Properties dialog box by right-clicking the project node and choosing Properties. Select the Libraries node in the Categories pane. Then select the JAR with which you want to associate the Javadoc and click Edit. You can then specify the sources to be associated.

    A class library can contain multiple JAR files as well as their Javadoc documentation and source code.

  4. In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.

  5. Click OK to exit the Ant Library Manager.

2.15.2 How to Add the JDK Javadoc to the IDE

To add JDK Javadoc to the IDE:

  1. Choose Tools > Java Platforms from the main window.

  2. Select the platform to which you want to add Javadoc in the left panel of the dialog box.

  3. In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files. Click Close.

2.15.3 How to View Javadoc Documentation

Once you have added a Javadoc library to the project, you can view the documentation for any of the library's classes in the Source Editor, browse the documentation in your external browser, and search the library using the Javadoc Index Search.

To view Javadoc documentation for any elements of code you are writing, you must add the Javadoc library containing the documentation to the project.

To view Javadoc documentation:

  • In the Source Editor, place the pointer on the code element whose documentation you want to display and do one of the following:

    • Choose Source > Show Documentation (or press Ctrl-Shift-Space) to view Javadoc documentation for the selected element in a separate IDE window.

    • Press Alt-F1 to view Javadoc documentation in an external browser window.

    • Choose Window > Other > Javadoc to open the Javadoc page that will show Javadoc dynamically for the code elements you are editing.

  • Choose Help > Javadoc Index Search (Shift-F1). The Javadoc Index Search window opens in a Source Editor tab and displays results for the presently selected code element in the Source Editor. In the preview window that opens, you can browse Javadoc documentation as if it is opened in a browser. Click the Toggle the Display of the HTML Viewer button to change between the HTML viewer views for the Javadoc documentation.

2.15.4 How to Generate Javadoc Documentation

For each of your projects, you can produce a set of Javadoc HTML pages that describe the project's classes, inner classes, interfaces, constructors, methods, and fields. The Javadoc is constructed from the structure of your code and the Javadoc comments embedded in your code. You can also configure how the IDE generates Javadoc documentation for each of your projects.

To generate Javadoc documentation for a project:

  1. Select the project in the Projects window.

  2. Choose Run > Generate Javadoc for Project.

The IDE generates the Javadoc to the dist/javadoc folder in your project directory and opens the index page in the IDE's designated web browser.

You can select multiple projects in the Projects window and generate Javadoc documentation for them at once by choosing Run > Generate Javadoc (number of selected projects) Projects from the main IDE's menu.

To configure how the IDE generates Javadoc documentation:

  1. In the Projects window, right-click the project node and choose Properties.

  2. Expand the Build node and select Documenting in the left pane of the dialog box.

  3. Set the desired options and click OK.

Note:

In Free-form projects the Generate Javadoc command is disabled by default. If your Ant script contains a target for generating Javadoc documentation, you can map the target to the Generate Javadoc command in the Project Properties dialog box's Build and Run panel.

2.15.5 How to Enter Javadoc Comments in Source Code

You can use editor hints to automatically generate basic Javadoc comments for code elements in your source files. The generated comments include required tags for the particular code element. For example, if a method takes a parameter, a @param tag is inserted. You can also use hints to generate corrections to Javadoc comments, such as when the comments contain incorrect tags.

You are notified of an editor hint by a light bulb icon that appears in the left margin of the Source Editor. You can read the hint by clicking the light bulb icon or by pressing Alt-Enter. You can generate the code suggested by the hint by clicking the hint or by pressing Enter.

The hints for Javadoc generation are turned off by default.

To turn on hints for Javadoc comments:

  1. Choose Tools > Options > Editor > Hints.

  2. On the Hints tab, select Java from the Language drop-down list.

  3. Select the Javadoc checkbox or expand it to fine-tune your choice.

By default, the Javadoc hints work for protected elements and public elements. If you would like to change the scope of the hints, expand the Javadoc node and select one of the subnodes. Then choose the radio button for the scope to which you would like the hints to apply.

For more information about Javadoc tags, see:

http://java.sun.com/javase/6/docs/technotes/tools/solaris/javadoc.html

For information on how to write Javadoc comments, see:

http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html

2.16 Viewing IDE Notifications

The Notifications window displays a list of all notifications that occurred in the current IDE session. Notifications indicate the change in the status of various IDE processes, including available IDE updates, the status of builds and test results. A new notification is indicated by a notification icon in the status bar of the IDE. The notification icon is displayed in the status bar until you view the notification.

How to view IDE notifications:

  1. Perform either of the following to view a list of notifications.

    • Click the Notifications icon in the status bar, if available.

    • Choose Window > IDE Tools > Notifications from the main menu.

  2. Click a notification in the list to display details about the notification.