Ejemplo n.º 1
0
  /** Starts the {@link UserAction} and updates the action label. */
  private void startAction(final UserAction action) {
    if (action.canStart()) {
      // System.out.println("Starting: " + action.getActionName());
      // show the action name
      String txt = "Action: " + action.getActionName() + " ";
      tool.setOutputText(txt);

      // run this later to let the above output be painted to the GUI first
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              // call actionPerformed() instead of startAction() to fire the events
              action.actionPerformed(new ActionEvent(action, 0, action.getActionName()));

              // clear the output after 1 second
              tool.clearOutputText(1000);
            }
          });
    }
  }