Jumping to Related Places in the NetBeans Java Editor

I learned something interesting about the NetBeans Java Editor today. Say you have an import statement (or anything else) selected, as here:

Now look at those browny-greeny marks in the right sidebar. When you click them, the cursor jumps to places where the selected item is used. So, in the case of import statements, you can click the browny-greeny mark and then find yourself in places in the code where you're doing something with that class.

I never knew that and it's pretty cool.


Yeah personally I use that all the time as a simple but very fast "find occurrences".

It would be even better though if a preview could be shown as you hover over the mark occurrences gutter, such that you did not necessarily have to click and go there, if all you really want is to inspect something.
At the same time, this hover preview functionality could be used for when hovering a block of folded code! ;)

Posted by Casper Bang on August 25, 2008 at 04:48 AM PDT #

No need to select anything. Just move the caret into the identifier. Once it is highlighted in for the usual "mark occurrences" feature, use Alt-Up/Down to jump to various usages (cycling back to the definition). Handy way to quickly jump to usages of imports, or private fields / methods / constructors / nested classes.

Posted by Jesse Glick on August 25, 2008 at 05:52 AM PDT #

I feel like I just lost the probably only chance I had to reverse the roles and actually teach you something.

Yesterday I could have sent you an email like "by the way, do you know about the jump-to-highlighting stuffs in the right side column?". Instead of that, I spent my time to read your tutorials.

I feel so frustrated :-)

Posted by Vincent Cantin on August 25, 2008 at 10:18 AM PDT #

I knew this, and forgot to blog about, or create a doc for it..Damn!

Anyways, its really cool stuff!

Enjoy learning ;-)

Posted by Varun on August 25, 2008 at 03:25 PM PDT #

Similar case is for the class you implement. When you put the cursor on that className, then it would mark occurrences for the implemented methods.

Not sure about Inheritance (extends).

Posted by Varun on August 25, 2008 at 03:27 PM PDT #

yeah! used this feature before :)

Posted by lunaticbd on August 25, 2008 at 03:41 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2016