Incorrect positioning of arrow icon in parent JMenu in Windows L&F

XMLWordPrintable

    • b08
    • windows

        ADDITIONAL SYSTEM INFORMATION :
        Windows system LAF on Windows 11.

        A DESCRIPTION OF THE PROBLEM :
        With Windows LAF the chevron-icon used for a parent JMenu to indicate sub-items is overdrawn when using a long text for the JMenu-label. In previous versions there would still be a small gap between the text and the chevron-icon.
        this is possibly related to JDK-8348760 as it changed the handling and distribution of the available space for the Menu(Item).

        REGRESSION : Last worked in version 21.0.7

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Please compile and run the attached demo to reproduce the issue. The problematic component is a JMenu with text "Really long Menu-Text" in a Popupmenu accessible by right-clicking the version-label in the demo.

        ---------- BEGIN SOURCE ----------
        import java.awt.BorderLayout;
        import java.lang.management.ManagementFactory;

        import javax.swing.*;

        class LargeMenuTextDemo {
        public static void main(String[] args) throws Throwable {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFrame frame = new JFrame("LargeMenuTextDemo");
        frame.setSize(300, 150);
        frame.setLocationRelativeTo(null);
        frame.setLayout(new BorderLayout());
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(new JCheckBoxMenuItem("CheckBox On", true));
        popupMenu.add(new JCheckBoxMenuItem("CheckBox Icon On", UIManager.getIcon("FileView.floppyDriveIcon"), true));
        popupMenu.add(new JCheckBoxMenuItem("CheckBox Icon Off", UIManager.getIcon("FileView.floppyDriveIcon"), false));

        JMenu menu = new JMenu("Really long Menu-Text");
        menu.add(new JMenuItem("Sub-MenuItem"));
        menu.add(new JCheckBoxMenuItem("Sub-CheckBox On", true));

        popupMenu.add(menu);

        JLabel lbl = new JLabel(ManagementFactory.getRuntimeMXBean().getVmVersion());
        lbl.setComponentPopupMenu(popupMenu);
        frame.add(lbl, BorderLayout.CENTER);

        frame.setVisible(true);
        }

        }

        ---------- END SOURCE ----------

        FREQUENCY :
        ALWAYS

              Assignee:
              Prasanta Sadhukhan
              Reporter:
              Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: