code: public boolean isInState(JComponent c) {
          for (Component comp = (Component) c; comp != null; comp = ((Container) comp).getParent()) {
  
              if (comp instanceof JToolBar) {
                  return true;
              } else if (!(comp instanceof Container)) {
                  break;
              }
          }
  
          return false;
      }
docs: {@inheritDoc}