code: public boolean isInState(JComponent c) {
          Component parent = c;
  
          while (parent.getParent() != null) {
  
              if (parent instanceof RootPaneContainer) {
                  break;
              }
  
              parent = parent.getParent();
          }
  
          if (parent instanceof JFrame) {
              return (((JFrame) parent).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
          } else if (parent instanceof JInternalFrame) {
              return ((JInternalFrame) parent).isMaximum();
          }
  
          return false;
      }
docs: {@inheritDoc}