Wednesday, June 8, 2011

Hierarchy View in Project Panel of NetBeans IDE

This post will cover following topics, questions:

  • How to change the package display type in NetBeans IDE?
  • How to see packages as hierarchical tree in the Projects Panel of NetBeans IDE?
  • Where is the menu to change List view to Tree view for packages in NetBeans IDE?
  • Customizing the display of Projects Panel in NetBeans IDE.
The preferences for how to see the package hierarchy in Projects Panel change from developer to developer.  Some times I like the flat display of the default NetBeans IDE Projects Panel which shows all the packages one below the other and all the classes in the package as a list below the package fully qualified name.  This makes the Projects panel only 4 node deep.

NetBeans IDE also allows us to change the display mode from List to Tree for the packages.  So instead of flat fully qualified name mode we can change the display to Tree like hierarchy mode where all the folders will also be converted to nodes and the depth of the Projects Panel tree will be deeper.

To do this we have to right click on an empty area of the Projects Panel.  The "View Java Packages As" menu only appears when we right click on an empty space of the Projects Panel.  This menu has two options and the List one is selected by default.  We can choose the Tree option to change the display of the Projects Panel to hierarchy mode.

When we change the mode to hierarchy the display looks more or less like the Files panel and the packages are shown as folder nodes.  This also makes the tree deeper according to how deep the packages are in hierarchy.

It is good to know the way to switch between these modes so that we can change the mode for some time if we want and again change it back to what it was.

The NetBeans IDE remembers your last choice by saving the preference in user directory, so when the NetBeans IDE is opened again next time the Tree mode or List mode of the Projects Panel is maintained.  

with regards
Tushar Joshi, Nagpur