Well, I think the Lookup isn't supposed to be used like that from an designer's perspective. It's not a bag of objects where anyone external can just add/remove stuff (although it can be used like this).
It's more of a way for "myObject" to expose his capabilities.
So, some normal usage would be: myObject.doSomething(myAddedObject) which *internally* might do something similar to instanceContent.add(myAddedObject) but it also might do something else that changes his lookup.
If you really want to use your code the way you wrote it, bear in mind that the InstanceContent isn't *added* to the lookup, so you can't search for it. InstanceContent *is* the model for the AbstractLookup class and you basically have to keep a reference to it somewhere if you want to change the lookup (for example myObject.getInstanceContent().add(myAddedObject) would do the trick although it's an ugly API).
--emi
On Sat, Jul 4, 2009 at 1:56 PM, Klaus Martinschitz
<klausmartinschitz@...> wrote:
Hi!
Does anyone know if something like this is possible?
InstanceContent instanceContent=new InstanceContent();
AbstractLookup abstractLookup=new AbstractLookup(instanceContent);
...
myObject.getLookup().lookup(InstanceContent.class).add(myAddedObject);
....
It does not work in this way becaus AbstractLookup doesn't save the
instance content object in its lookup. I just want to understand how to
add objects to lookups dynamically..
Thanks,
BYe,
Klaus
--
Emilian Bold
http://www.emilianbold.ro :Java and NetBeans Platform-loving development from Timisoara, Romania.
http://www.josekibold.ro : Java / iPhone development.