ADM CJavaMenuItem/CShellMenuItem Widgets
(Since adm V0.3)

The ADM package provides two menu items, CJavaMenuItem and CShellMenuItem. These two menu items are subclasses of awt.MenuItem and are used to lanuch another java class or shell program. They are the invisible beans and must be added to a CMenuButton widget. Unlike awt.MenuItem, the action event is already built into these widgets. The user does not need to implement the ActionListener.

CShellMenuItem is used to launch any non-java program. The name of this program must be set through setShellCommand (String cmd) method. When this menu item is selected, the built-in action is to disable the menu Item and start a new thread to execute the program. This thread will fork a process and wait until the program exits. It then re-enables the menu item.

CJavaMenuItem is used to invoke a java application within the same virtual machine. The name of this application must be set through the setClassName (String javaName) method. The setParams (String[] params) method must be called to pass the correct argument if the application takes any argument. The application invoked by the CJavamenuItem is required to provide a null constructor and a static method main (String args[]) (after release 1.0) or static execute (String args[]) (before release 0.4).

The built-in action for CJavaMenuItem is to invoke the application main method with passed arguments. How the application behave is controlled by the user's application. Since adm Version 1.0 two abstract classes CNamedApplication and CSingletonApplication are provided for user to develop the named application and singleton application invoked by CJavaMenuItem. A application App.java is provided here to demonstrate how to use CJavaMenuItem and CShellMenuItem. This application contains CMenuButtons with CJavaMenuItem and CShellMenuItem. The application NamedApp.java and SingletonApp.java invoked by the CJavaMenuItem are also available here.

The default label is String "[J]" for CJavaMenuItem and "[!]" for CShellMenuItem (Fig. 1). If user set the label, the "[J] "+label or "[!] "+label will be the real label to distinguish them from awt.MenuItem.

Fig. 1 The CMenuButtons with
CJavaMenuItems/CSheelMenuItem