code: private void assembleSystemMenu() {
          systemPopupMenu = new JPopupMenuUIResource();
          addSystemMenuItems(systemPopupMenu);
          enableActions();
          menuButton = new NoFocusButton("InternalFrameTitlePane.menuButtonAccessibleName");
          updateMenuIcon();
          menuButton.addMouseListener(new MouseAdapter() {
                  public void mousePressed(MouseEvent e) {
                      try {
                          frame.setSelected(true);
                      } catch (PropertyVetoException pve) {
                      }
  
                      showSystemMenu();
                  }
              });
  
          JPopupMenu p = frame.getComponentPopupMenu();
  
          if (p == null || p instanceof UIResource) {
              frame.setComponentPopupMenu(systemPopupMenu);
          }
  
          if (frame.getDesktopIcon() != null) {
              p = frame.getDesktopIcon().getComponentPopupMenu();
  
              if (p == null || p instanceof UIResource) {
                  frame.getDesktopIcon().setComponentPopupMenu(systemPopupMenu);
              }
          }
  
          setInheritsPopupMenu(true);
      }
docs: Create the system menu.