code: private void showSystemMenu() {
          Insets insets = frame.getInsets();
  
          if (!frame.isIcon()) {
              systemPopupMenu.show(frame, insets.left, getY() + getHeight());
          } else {
              systemPopupMenu.show(menuButton, getX() - insets.left - insets.right,
                                   getY() - systemPopupMenu.getPreferredSize().height - insets.bottom - insets.top);
          }
      }
docs: Show the system menu.