Exemplo n.º 1
0
  /**
   * Send the initial set of events to the appletviewer event queue. On start-up the current
   * behaviour is to load the applet and call Applet.init() and Applet.start().
   */
  private void initEventQueue() {
    // appletviewer.send.event is an undocumented and unsupported system
    // property which is used exclusively for testing purposes.
    String eventList = System.getProperty("appletviewer.send.event");

    if (eventList == null) {
      // Add the standard events onto the event queue.
      panel.sendEvent(AppletPanel.APPLET_LOAD);
      panel.sendEvent(AppletPanel.APPLET_INIT);
      panel.sendEvent(AppletPanel.APPLET_START);
    } else {
      // We're testing AppletViewer.  Force the specified set of events
      // onto the event queue, wait for the events to be processed, and
      // exit.

      // The list of events that will be executed is provided as a
      // ","-separated list.  No error-checking will be done on the list.
      String[] events = splitSeparator(",", eventList);

      for (int i = 0; i < events.length; i++) {
        System.out.println("Adding event to queue: " + events[i]);
        if (events[i].equals("dispose")) panel.sendEvent(AppletPanel.APPLET_DISPOSE);
        else if (events[i].equals("load")) panel.sendEvent(AppletPanel.APPLET_LOAD);
        else if (events[i].equals("init")) panel.sendEvent(AppletPanel.APPLET_INIT);
        else if (events[i].equals("start")) panel.sendEvent(AppletPanel.APPLET_START);
        else if (events[i].equals("stop")) panel.sendEvent(AppletPanel.APPLET_STOP);
        else if (events[i].equals("destroy")) panel.sendEvent(AppletPanel.APPLET_DESTROY);
        else if (events[i].equals("quit")) panel.sendEvent(AppletPanel.APPLET_QUIT);
        else if (events[i].equals("error")) panel.sendEvent(AppletPanel.APPLET_ERROR);
        else
          // non-fatal error if we get an unrecognized event
          System.out.println("Unrecognized event name: " + events[i]);
      }

      while (!panel.emptyEventQueue()) ;
      appletSystemExit();
    }
  }