/**
   * Method declaration
   *
   * @param b
   * @param name
   * @param items
   */
  void addMenu(MenuBar b, String name, String items[]) {

    Menu menu = new Menu(name);

    addMenuItems(menu, items);
    b.add(menu);
  }
  public static void startApplet(
      Applet applet, String title, Hashtable params, int width, int height) {

    applet1 = applet;
    // setup so as getParameter, etc, will work
    OurAppletContext newAppletContext = new OurAppletContext(applet.getToolkit());
    OurAppletStub newAppletStub = new OurAppletStub(newAppletContext, params);
    applet.setStub(newAppletStub);

    // create new application frame window
    AppletFrame f = new AppletFrame(title + extraTitle);

    // add applet to frame window
    f.add("Center", applet);

    // add a quit menu item
    MenuBar menubar = new MenuBar();
    Menu file = new Menu("File", true);
    MenuItem item = new MenuItem("Quit");
    menubar.add(file);
    file.add(item);
    f.setMenuBar(menubar);
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // At this point, we simply leave.
            java.lang.Runtime.getRuntime().exit(0);
          }
        });

    // resize frame window to fit applet
    f.pack();
    f.setSize(width, height);
    applet.setSize(width, height);

    // initialize the applet
    applet.init();
    applet.start();

    // show the window
    f.show();

    f.repaint();
  } // end startApplet()
  /** Method declaration */
  void main() {

    fMain = new Frame("HSQL Database Manager");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));

    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);

    MenuBar bar = new MenuBar();

    // used shortcuts: CERGTSIUDOLM
    String fitems[] = {
      "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit"
    };

    addMenu(bar, "File", fitems);

    String vitems[] = {
      "RRefresh Tree", "--", "GResults in Grid", "TResults in Text",
      "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command",
      "4Enlarge Command"
    };

    addMenu(bar, "View", vitems);

    String sitems[] = {
      "SSELECT",
      "IINSERT",
      "UUPDATE",
      "DDELETE",
      "--",
      "-CREATE TABLE",
      "-DROP TABLE",
      "-CREATE INDEX",
      "-DROP INDEX",
      "--",
      "-CHECKPOINT",
      "-SCRIPT",
      "-SET",
      "-SHUTDOWN",
      "--",
      "-Test Script"
    };

    addMenu(bar, "Command", sitems);

    Menu recent = new Menu("Recent");

    mRecent = new Menu("Recent");

    bar.add(mRecent);

    String soptions[] = {
      "-AutoCommit on",
      "-AutoCommit off",
      "OCommit",
      "LRollback",
      "--",
      "-Disable MaxRows",
      "-Set MaxRows to 100",
      "--",
      "-Logging on",
      "-Logging off",
      "--",
      "-Insert test data"
    };

    addMenu(bar, "Options", soptions);

    /* NB - 26052002 Restore is not implemented yet in the transfer tool */
    String stools[] = {"-Dump", /*"-Restore",*/ "-Transfer"};

    addMenu(bar, "Tools", stools);
    fMain.setMenuBar(bar);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    initGUI();

    sRecent = new String[iMaxRecent];

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();

    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
      fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
      fMain.setLocation(0, 0);
      fMain.setSize(d);
    }

    fMain.show();

    // (ulrivo): load query from command line
    if (defScript != null) {
      if (defDirectory != null) {
        defScript = defDirectory + File.separator + defScript;
      }

      txtCommand.setText(DatabaseManagerCommon.readFile(defScript));
    }

    txtCommand.requestFocus();
  }