import java.awt.*; import adm.*; /** * A java window application which using the adm.CMenuButton, * CJavaMenuItem and CSheelMenuItem widgets. * It takes one argument - the port number on which the testServer * running on. It is assumed the application and testServer are * running on same platform. */ public class App extends CApplication { public static void main(String[] args) { if (args.length != 1) { System.out.println("java App port"); System.exit(0); } int port = Integer.parseInt(args[0]); Frame f = new App(port); f.setBounds(200, 100, 150, 100); f.show(); } public App (int port) { super("Localhost", port, "Demo"); setLayout(new GridLayout(2, 1, 10, 10)); // add CMenuBotton labeled "Simple Demo" CMenuButton B1 = new CMenuButton("Simple Demo"); add(B1); // add CMenuBotton labeled "Named App Demo" CMenuButton B2 = new CMenuButton("Named App Demo"); add(B2); /** * add menuItem labeled "Multi Instance" to start the * multi instance of application "MultiApp". * Every time this menu item is pressed, a new instance * (window) will be shown up since there is no book keeping * function implemented in MultiApp.java. */ CJavaMenuItem a0 = new CJavaMenuItem("Multi Instance"); a0.setClassName("MultiApp"); B1.add(a0); /** * add menuItem labeled "Singleton Application" to invoke the * application "SingletonApp". SingletonApp takes no argument. * It is not necessary to overwrite the setArgs method. */ CJavaMenuItem a1 = new CJavaMenuItem("Singleton Application"); a1.setClassName("SingletonApp"); B1.add(a1); /** * add a CShellMenuItem labeled "Run a cmd" to run command * "/bin/touch App.java" */ CShellMenuItem s = new CShellMenuItem("Run a command"); s.setShellCommand("/bin/touch App.java"); B1.add(s); /** * Add menuItem labeled "R124 set point" to invoke the * application "NamedApp". NamedApp takes two argument "R124" * and "GSET". The first one "R124" is the name of the instance. * There is only one instance with "R124" name will be start up. */ CJavaMenuItem a2 = new CJavaMenuItem("R124 set point"); a2.setClassName("NamedApp"); String[] params2 = {"R124", "GSET"}; a2.setParams(params2); B2.insert(a2, 2); /** * Add menuItem labeled "R124 measure point" to invoke the * application "NamedApp". It takes arguments "R124" and "GMES". * If "R124 measure point" is pressed after the "R124 set point", * no new window will be started. The parameters in first window * will be reset and shown in the front. */ CJavaMenuItem a3 = new CJavaMenuItem("R124 measure point"); a3.setClassName("NamedApp"); String[] params3 = {"R124", "GMES"}; a3.setParams(params3); B2.add(a3); /** * Add menuItem labeled "R125 set point" to invoke the * application "NamedApp". It takes arguments "R125" and "GSET". * A new instance will be started even the "R125 measure point" * or "R124 set point" is pressed first since they have different * name (args[0]). */ CJavaMenuItem a4 = new CJavaMenuItem("R125 set point"); a4.setClassName("NamedApp"); String[] params4 = {"R125", "PSET"}; a4.setParams(params4); B2.add(a4); } public Insets getInsets() { return new Insets(20, 20, 20, 10); } }