Re: Confusion about Action members
[email protected] Sun, 24 Jul 2005 22:25:00 +0200
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Hi! > > Can Action objects work like this? > > public class MyMenuItem extends JMenuItem { > > public static Action MyAction = SomeStaticClass.getAction(); > > } > > > where SomeStaticClass has a selection of general actions that can be > used by many other client classes, eg we could declare a public class > MyButton similarly and use the same action. > > MyMenuItem is registered for the tag <menuitem> and MyButton for <button> > > This way I wanted the Actions specified in the XML as > > <menubar> <menu name='file'> > <menuitem name='open' Action='MyAction'/> > </menu> > </menubar> > > to work similarly to one declared for a button. IMHO it is much simpler than that. I usally use a class like this: public class MyAction extends AbstractAction { public static Action getInstance() { return myInstance; } ... } Then you may specify <button initclass="MyAction"/> <menuitem initclass="MyAction"/> Hope it helps and I understood your requirements... Greetings from dark and late Berlin, Frank > > I guess my question boils down to whether the reflection mech. is looking > only for public instance members, or also static ones.. UPDATE doesn't seem > to work even if I remove static.. > > thanks! > Nandan > > > _______________________________________________ > Forum mailing list > [email protected] > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com >