ADM CNamedApplication/CSingletonApplication Widgets
(Since adm V1.0)

Create a named application or singleton application invoked by CJavaMenuItem widget. And initializes a connection to a server, typically a gateway such as cdevGateway if it is not connected.

The child class must provide a null constructor and the main method. It is also necessary to overwrite setArgs(String[]) method if there is any argument needed to be passed. Two sample classes SingletonApp.java and NamedApp.java are provided to demonstrate the usage of these C*Application widgets.

The book keeping function is implemented in these two classes. There is a static class pointer defined in CSingletonApplication to keep tracking the instance. Only one instance will be invoked in same virtue machine if the application extends the CSingleApplication. The application SingletonApp.java is a example of using the CSingletonApplication class.

It is better to extend the CNamedApplication when more instances are needed. CNamedApplication is a subclass of CApplication and has a static hash table to keep track the running instance. Every time when the menu button is pressed, the CNamedApplication will search the hash table to find the instance with same name (args[0]). If the instance is found, the arguments will be reset (call application's setArgs method) and then the window will be brought to the front. If not found a new instance will be started up. By passing different argument the user can control the number of instance (window). Only one instance per name (using args[0] as the name or the empty string "" if no argument) will be shown up. Class App.java demonstrates how to invoke a named application with different parameters to bring up controllable frame or to change the content of the application frame dynamically.

When a application extends CApplication or awt.Frame and no book keeping work implemented, a new instance will be shown up every time when user press the menu button. Most time this behavior is not what users want. In this case it is better to choice CNamedApplication or CSingletonApplication as the parent class. Or implement their own book keeping function if the application already extends another class. But for some quick non GUI application, the book keeping function is not necessary if it is designed to run the program every time the button is pressed.

Put these all together we provided App.java which using CMenuButtons with C*MenuItem to invoke the multi-instance application MultiApp, singleton application SingletonApp and named application NamedApp. A tar file contains these sample codes and README file is also available for download.