DevFaqLookupImplement

How do I implement my own lookup or proxy another one?

It is not uncommon to be subclassing a class, such as TopComponent or Node which has a method getLookup(), and to need to add to or filter the original Lookup's contents. There are a number of convenience factories and classes which make it easy to do this:

  • ProxyLookup - a Lookup which takes an array of Lookups and merges them together. Typical use is taking an existing lookup and providing it plus a lookup created with one of the convenience methods below
  • Lookups.fixed(Object... arr) - a static method that creates a Lookup with an array of persistent objects as its contents
  • Lookups.singleton (Object single) - a static method that creates a Lookup with one object as its content
  • AbstractLookup - a Lookup which can have dynamic content - use it in conjunction with InstanceContent, which you can add/remove things from

If you need to customize a Node's lookup, read the FAQ item on how to do that.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo