/** Called when the penlet is activated by menu */
  public void activateApp(int reason, Object[] args) {
    // gamestate
    gamestate = actapp;

    // add listeners
    this.context.addStrokeListener(this);
    context.addPenTipListener(this);

    // Configure the ICR context
    this.icrContext = this.context.getICRContext(1000, this);
    Resource[] resources = {
      this.icrContext.getDefaultAlphabetKnowledgeResource(),
      // this.icrContext.createLKSystemResource(ICRContext.SYSRES_LK_WORDLIST_100K),
      this.icrContext.createSKSystemResource(ICRContext.SYSRES_SK_DIGIT)
    };
    this.icrContext.addResourceSet(resources);

    // create the menu
    this.menuBrowseList = new BrowseList(this.vectorMenuItems, null);

    // load image streams
    Class myPenLetClass = this.getClass();
    inputstreamImage = myPenLetClass.getResourceAsStream("/images/Bull.arw");

    try {
      imageBull = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageBull = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/Cow.arw");
    try {
      imageCow = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageCow = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/Wrong.arw");
    try {
      imageWrong = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageWrong = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/Help.arw");
    try {
      imageHelp = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageWrong = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/AdvancedMode.arw");
    try {
      imageAdvanced = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageAdvanced = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/InterMediateMode.arw");
    try {
      imageInter = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageInter = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/BasicMode.arw");
    try {
      imageBasic = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageBasic = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/GBGuesses.arw");
    try {
      imageGameBoard = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageGameBoard = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/GBClear.arw");
    try {
      imageClearButton = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageClearButton = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/GBSound.arw");
    try {
      imageSoundButton = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageSoundButton = null;
    }

    inputstreamImage = myPenLetClass.getResourceAsStream("/images/GBNewGame.arw");
    try {
      imageNewGameButton = Image.createImage(inputstreamImage);
    } catch (IOException e) {
      imageNewGameButton = null;
    }

    if (reason == ACTIVATED_BY_MENU) {

      // display the first menu item
      this.display.setCurrent(this.menuBrowseList);
      currentMenuSelection = this.menuBrowseList.getFocusIndex();
      playMenuPrompt(currentMenuSelection);
    } else {
      /* activated by another event. state that codebreaker active
      and launch into new game */
      String[] filenames;
      filenames = new String[3];
      filenames[0] = "codebreaker";
      filenames[1] = "newgame";
      filenames[2] = "rectangle";
      playSound(filenames);
      gamestate = newGame(false);
    }
  }