/**
   * Changes letter case.
   *
   * @param typeOfCase The type that the case should be changed to
   */
  public void changeCase(String typeOfCase) {
    if (textarea.selectedTextProperty().length().get() == 0) {
      textarea.selectAll();

      if (textarea.selectedTextProperty().length().get() == 0) {
        return;
      }
    }

    String result = TextUtilities.changeCase(textarea.getSelectedText(), typeOfCase);

    int start = textarea.getSelection().getStart();
    textarea.replaceSelection(result);
    textarea.selectRange(start, start + result.length());
  }