Download NetBeans!

20061128 Tuesday November 28, 2006

NetBeans Keyboard Shortcut of the Week (6)

I discovered something purely by chance yesterday (hurray for serendipity). Let's say you have this import statement:

import java.io.BufferedReader;

If you put the cursor in "BufferedReader" above and then press Alt-O, the IDE opens the "BufferedReader" source. No surprise there, right? The key binding Alt-O is "Go to Source" and so, when you put the cursor on the name of a class, and then press Alt-O, you see the source.

However, what happens when you put the cursor on "java" or on "io" in the import statement above? Now you're not in the name of a class, but in the name of a package. Put the cursor in "java" for example and then press Alt-O again. And look... wow... a whole new explorer window appears, with the name of the package in the title bar and all the subpackages within the package displayed, which you can browse and you can open the classes and look at them inside the editor:

Pretty cool. I never knew this was possible. Makes NetBeans even more of a learning tool than I had thought it was. This is definitely worthy of being the 'keyboard shortcut of the week', with pride of place in the left sidebar of this blog.

Nov 28 2006, 01:38:08 AM PST Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/netbeans_keyboard_shortcut_of_the4
Comments:

would be it possible to associate Alt+O (view source) to a mouse click? (ala IDEA)

Posted by 80.38.101.173 on November 28, 2006 at 03:24 AM PST #

That's already possible, 80.38.101.73. Hold down the Ctrl key, move the mouse over the identifier, click the identifier which is now a hyperlink, and you're in the source.

Posted by Geertjan on November 28, 2006 at 03:30 AM PST #

Oops. Seems I misnamed you. I meant ".173", not "73".

Posted by Geertjan on November 28, 2006 at 03:32 AM PST #

yes, it's true... and wihout the Ctrl key?, only with mouse button?

Posted by Jorge M. on November 28, 2006 at 03:51 AM PST #

Hi Jorge. Well, the identifier needs to be a hyperlink before you can click it. That's why you need to use the Ctrl key -- otherwise the identifier is not a hyperlink. What you're asking for is for the hyperlinks to always be present. I agree that would be nice -- to have an option that turns all hyperlinks on at the same time, without you needing to hold down the Ctrl key. (But it should be an option, not enabled by default, because not everyone will want to see hyperlinks everywhere.) You can go to Issuezilla and add this as an enhancement request.

Posted by Geertjan on November 28, 2006 at 03:56 AM PST #

This Alt-O tip is cool; however, it isn't the same as holding down control while clicking on a package name part- at least not on my NB55 installation. Only Alt-O brings up the new explorer window. Ctrl-click simply results in a message in the status line that says that the targeted package cannot be opened, i.e.: 'Cannot open element "spring.framework"' This isn't a complaint, but a clarification. The bottom line: NetBeans ROCKS!

Posted by Kurt Risser on November 28, 2006 at 07:36 AM PST #

Yes, that's right, Kurt. The hyperlink thing doesn't work for package names, just for classes. But the Alt-O thing works for both packages and classes, except that for packages it does the different thing of popping open the explorer window. Thanks for the clarification and also for agreeing with my underlying assertion -- NetBeans rocks!

Posted by Geertjan on November 28, 2006 at 08:05 AM PST #

Wow, that is cool!!!!

Posted by Rory on November 28, 2006 at 08:56 AM PST #

go

Posted by 125.24.192.117 on April 17, 2008 at 12:32 AM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed