code: private String getTitle() {
          if (rootParent instanceof JFrame) {
              return ((JFrame) rootParent).getTitle();
          } else if (rootParent instanceof JDialog) {
              return ((JDialog) rootParent).getTitle();
          }
  
          return null;
      }
docs: Returns the String to display as the title.
  
  @return the title String.