import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;

/**
 *
 * @author medge
 */
public class JPopupMenuIssue extends JFrame {
    private final String caption =
            """
            <html>Right click on this.<br />
            First when the bottom part is not over the task bar and it works.<br />
            Second when the bottom part is over the task bar and it fails.</html>
            """;

    private final JPopupMenu mnuIssue = new JPopupMenu();
    private final JLabel lblIssue = new JLabel(caption);

    private JPopupMenuIssue() {
        for (int i = 0; i < 10; i++) {
            JMenuItem item = new JMenuItem("Menu " + i);
            mnuIssue.add(item);
        }
        JPanel pnl = new JPanel(new BorderLayout());
        pnl.add(lblIssue, BorderLayout.SOUTH);
        lblIssue.setComponentPopupMenu(mnuIssue);
        setContentPane(pnl);
        pack();
    }

    public static void main(String[] args) {
        JPopupMenuIssue x = new JPopupMenuIssue();
        x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        x.setBounds(10, 10, 500, 500);
        x.setVisible(true);
    }

}

