Geertjan's Blog

  • November 28, 2006

NetBeans Keyboard Shortcut of the Week (6)

Geertjan Wielenga
Product Manager
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.

Join the discussion

Comments ( 10 )
  • guest Tuesday, November 28, 2006
    would be it possible to associate Alt+O (view source) to a mouse click? (ala IDEA)
  • Geertjan Tuesday, November 28, 2006
    That's already possible, 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.
  • Geertjan Tuesday, November 28, 2006
    Oops. Seems I misnamed you. I meant ".173", not "73".
  • Jorge M. Tuesday, November 28, 2006
    yes, it's true...
    and wihout the Ctrl key?, only with mouse button?
  • Geertjan Tuesday, November 28, 2006
    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.
  • Kurt Risser Tuesday, November 28, 2006
    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!
  • Geertjan Tuesday, November 28, 2006
    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!
  • Rory Tuesday, November 28, 2006
    Wow, that is cool!!!!
  • guest Thursday, April 17, 2008


  • satılık araba Saturday, September 13, 2008


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.