code: public JScrollPane getScrollPane(JTextComponent editorPane) {
          Container p = editorPane.getParent();
          while (p != null) {
              if (p instanceof JScrollPane) {
                  return (JScrollPane) p;
              }
              p = p.getParent();
          }
          return null;
      }
docs: Get the JscrollPane that contains an editor pane, or null if none.
  
  @param editorPane an editor pane
  @return the JscrollPane that contains the editor pane, or null if none