Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 23

Download

What is a TopComponent in the Window System?

org.openide.windows.TopComponent is a JComponent subclass which knows how to work with the NetBeans window system. If you want to add components to the main window, typically you will subclass TopComponent, using it the same way you would a JPanel.

TopComponents live inside Modes - docking containers.

TopComponents can have various states:

  • open/closed - When a TopComponent is open, a tab exists somewhere in the main window or UI for it

  • visible/invisible - When a TopComponent is visible, it is the selected tab in its Mode

  • active/inactive - When a TopComponent is active, it or a child component of it has keyboard focus, and it is currently the global selection context

Each TopComponent has a Lookup and one or more `activated Node`s. These define the selection context for the window system, which determines what actions (menu items, toolbar buttons, etc.) are enabled, and in some cases, what they will do or operate on if invoked.

`TopComponent`s are part of the Windows API.

TopComponents that were already open may be deserialized and reopened on restart. The template that NetBeans 5.0 provides includes code for this - it is actually using saved using the Externalizable interface. Whether or not it is saved is determined by what you return from getPersistenceType().

For information on how and when these are reconstructed on startup, see the gory details of the window system on startup.