NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed. (sponsored)
In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.
Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.
Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
The following are some of the many cool NetBeans IDE 6.0 keyboard shortcuts that no programmer will be able to do without, once you know they're there. Not all of these are new in 6.0, some were there before, but deserve to be highlighted because often they're overlooked:
Move/copy up/down.
Press Ctrl-Shift-Up and the current selection is copied to the lines right above the current selection. Press Alt instead of Ctrl and it is moved instead of copied. Press Down instead of Up and the lines of code will be copied below the current selection, as below:
Capture inner/outer syntactic element.
Each time you press Alt-Shift-Period, the selection expands to a successively wider syntactic element. For example, below one statement was selected, the key combination Alt-Shift-Period was pressed, and then the complete content of the surrounding block statement was shown to be selected. The selection expands from the current statement to surrounding block statements to the surrounding method and, from there, to the surrounding class and further. To successively narrow the selection, press Alt-Shift-Comma, instead of Alt-Shift-Period.
Generate code skeletons.
Whenever you want to generate commonly needed pieces of code, such as constructors, getters, and setters, simply click Alt-Insert, and a small popup appears with a list of items from which you can select:
Inplace rename.
If you want to change a variable, method, or other item, of which more than one are used in your code, press Ctrl-R, and you will see that all instances of the item turn blue at the same time, as shown below. Now, when you change the selected item, all the other instances change at the same time, until you press Escape, at which point the inplace rename mode comes to an end.
Add/Remove comment lines.
Select one or more lines, press Ctrl-/ and then the selected lines are commented out, as shown below. Press the same keys again and the commented lines will no longer be commented. This was, of course, also possible in previous releases, but previously there were two different keyboard shortcuts, one for commenting and one for uncommenting. Now that they have been combined into one shortcut, you can quickly toggle between comment and uncomment, which makes this activity much faster and more efficient.
Inspect members/hierarchy.
Both the members of the current class as well as its hierarchy can be displayed and then filtered. Press Alt-F12 and the ancestors of the current file are shown. On the other hand, if you press Ctrl-F12, the current file's members are displayed, as shown here:
Switch between documents.
When you have multiple documents open at the same time, press Ctrl and Tab, and then a small popup appears. You can scroll through the popup, which displays all the open documents, and then choose the document that you want to open:
Jump to last edit.
Often, you find yourself in a situation where you have edited in one document, while you currently find yourself in a completely different document. How do you get back to the place where you were last editing your code? That is likely to be the place where you want to get back to, in order to do some more editing. Now, whenever you click Ctrl-Q, the last edited document is found, and the cursor lands on the line where the last edit took place. Alternatively, you can click the button shown below, in the top left corner of the Source Editor:
Bookmarks.
When you press Ctrl-Shift-M, the current line is "bookmarked". What this means is that you can later quickly cycle back/forward to it (with Ctrl-Shift-Period and Ctrl-Shift-Comma). The bookmarked line gets a small icon in the left sidebar, as shown below, until you press Ctrl-Shift-M on the line again, to remove the bookmark:
Highlight exit points.
Place the cursor on the return type and you will immediately see all exit points highlighted:
10 Handy Editor Shortcuts in NetBeans IDE 6.0
At 9:42 PM on Oct 21, 2007, Geertjan wrote:
Fresh Jobs for Developers Post a job opportunity
Press Ctrl-Shift-Up and the current selection is copied to the lines right above the current selection. Press Alt instead of Ctrl and it is moved instead of copied. Press Down instead of Up and the lines of code will be copied below the current selection, as below:
Each time you press Alt-Shift-Period, the selection expands to a successively wider syntactic element. For example, below one statement was selected, the key combination Alt-Shift-Period was pressed, and then the complete content of the surrounding block statement was shown to be selected. The selection expands from the current statement to surrounding block statements to the surrounding method and, from there, to the surrounding class and further. To successively narrow the selection, press Alt-Shift-Comma, instead of Alt-Shift-Period.
Whenever you want to generate commonly needed pieces of code, such as constructors, getters, and setters, simply click Alt-Insert, and a small popup appears with a list of items from which you can select:
If you want to change a variable, method, or other item, of which more than one are used in your code, press Ctrl-R, and you will see that all instances of the item turn blue at the same time, as shown below. Now, when you change the selected item, all the other instances change at the same time, until you press Escape, at which point the inplace rename mode comes to an end.
Select one or more lines, press Ctrl-/ and then the selected lines are commented out, as shown below. Press the same keys again and the commented lines will no longer be commented. This was, of course, also possible in previous releases, but previously there were two different keyboard shortcuts, one for commenting and one for uncommenting. Now that they have been combined into one shortcut, you can quickly toggle between comment and uncomment, which makes this activity much faster and more efficient.
Both the members of the current class as well as its hierarchy can be displayed and then filtered. Press Alt-F12 and the ancestors of the current file are shown. On the other hand, if you press Ctrl-F12, the current file's members are displayed, as shown here:
When you have multiple documents open at the same time, press Ctrl and Tab, and then a small popup appears. You can scroll through the popup, which displays all the open documents, and then choose the document that you want to open:
Often, you find yourself in a situation where you have edited in one document, while you currently find yourself in a completely different document. How do you get back to the place where you were last editing your code? That is likely to be the place where you want to get back to, in order to do some more editing. Now, whenever you click Ctrl-Q, the last edited document is found, and the cursor lands on the line where the last edit took place. Alternatively, you can click the button shown below, in the top left corner of the Source Editor:
When you press Ctrl-Shift-M, the current line is "bookmarked". What this means is that you can later quickly cycle back/forward to it (with Ctrl-Shift-Period and Ctrl-Shift-Comma). The bookmarked line gets a small icon in the left sidebar, as shown below, until you press Ctrl-Shift-M on the line again, to remove the bookmark:
Place the cursor on the return type and you will immediately see all exit points highlighted:
3 replies so far (
Post your own)
Re: 10 Handy Editor Shortcuts in NetBeans IDE 6.0
Very useful tips,some I didn't know before,thanks.Java Tips -
Re: 10 Handy Editor Shortcuts in NetBeans IDE 6.0
I think my favorite is Ctrl-Shift-Semicolon.Say you're typing along and you end up in a situation like this:
list.add ("foo | ")(the | is the caret).
You've got a little problem because you have to take your hand off the keyboard and press the arrow keys to complete the line with a semicolon.
No more. Press ctrl-semicolon, and a ; is appended, but the caret doesn't move.
Press ctrl-shift-semicolon and a ; is appended, and a new line, properly indented is inserted with the caret placed at the beginning of it!
NetBeans.org
Evangelist/Senior Staff Engineer, Sun Microsystems
Re: 10 Handy Editor Shortcuts in NetBeans IDE 6.0
Extremely cool, thanks!