code: public boolean isInState(JComponent c) {
          Component parent = c;
  
          while (parent.getParent() != null) {
  
              if (parent instanceof Window) {
                  break;
              }
  
              parent = parent.getParent();
          }
  
          if (parent instanceof Window) {
              return ((Window) parent).isFocused();
          }
  
          // Default to true.
          return true;
      }
docs: {@inheritDoc}