Beispiel #1
0
  private final void getNewName(final Callback<String> callback) {
    final String title = "Get new random name";
    final String message = "What type of name do you want to generate?";
    final FSkinImage icon = FOptionPane.QUESTION_ICON;

    FOptionPane.showOptionDialog(
        message,
        title,
        icon,
        genderOptions,
        2,
        new Callback<Integer>() {
          @Override
          public void run(final Integer genderIndex) {
            if (genderIndex == null || genderIndex < 0) {
              callback.run(null);
              return;
            }

            FOptionPane.showOptionDialog(
                message,
                title,
                icon,
                typeOptions,
                2,
                new Callback<Integer>() {
                  @Override
                  public void run(final Integer typeIndex) {
                    if (typeIndex == null || typeIndex < 0) {
                      callback.run(null);
                      return;
                    }

                    generateRandomName(
                        genderOptions.get(genderIndex),
                        typeOptions.get(typeIndex),
                        screen.getPlayerNames(),
                        title,
                        callback);
                  }
                });
          }
        });
  }