Kate Rhodes wrote:
am I understanding this right? when you use InitClass it will initialize an instance of that class but not associate it with the current swing object?
No, this is not the case. Sorry I did not make myself very clear here...
or, are you saying that when you use that it will set whatever the new InitClass instance is as the action of the swing object?
Yes, this is right. The only thing I liked to avoid was the creation of an object which is not used at all. If the object maintains an expensive status, this expensive status is maintained -- whether the object is actually visible (i.e. the variable is mentioned in the xml) or not.
So, with the InitClass approach, I'm able to give the *type* of object I like to use as init parameter to the object (e.g. JButton). The idea with the factory method was to be able to create only one object of this type. If the type is not mentioned in the xml, no object of this type is created ever. Whereas if you create a variable I do not think the garbage collector will be so clever to remove the object if this object registers itself on several event-notifier objects. It may be the case with simple, stateless actions to be removed by garbage collection.
Frank
-kate
