Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8040630

Popup menus and tooltips flicker with previous popup contents when first shown

XMLWordPrintable

    • b16
    • os_x

        FULL PRODUCT VERSION :
        java version "1.7.0_40"
        Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
        Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin richard-laptop-2.local 12.5.0 Darwin Kernel Version 12.5.0: Mon Jul 29 16:33:49 PDT 2013; root:xnu-2050.48.11~1/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        When a JPopupMenu or tooltip is shown, it briefly displays the content of the last popup that was shown before the new content is painted. This is only noticeable when the contents of the popup takes a little while to paint.

        This can be quite noticeable and ugly in real programs where menus get quite big.

        REGRESSION. Last worked in version 6u45

        REGRESSION : Additional Information
        java version "1.6.0_51"
        Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
        Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Run the included example code
        2. Click on "Button 1"
        3. Click on "Button 2" and watch the popup menu closely

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        As soon as the "Button 2" popup is displayed it should show the new menu items.
        ACTUAL -
        For a fraction of a second the "Button 2" popup shows the contents of the "Button 1" popup.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public static void main(String[] args) {
                JFrame f = new JFrame();
                final JButton button1 = new JButton();
                button1.setAction(new AbstractAction("Button 1") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        JPopupMenu m = new JPopupMenu();
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.add(new JMenuItem("<html><b>#################</b></html>"));
                        m.show(button1, 0, button1.getHeight());
                    }
                });
                final JButton button2 = new JButton();
                button2.setAction(new AbstractAction("Button 2") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        JPopupMenu m = new JPopupMenu();
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.add(new JMenuItem("<html><font color=gray>--------------</font></html>"));
                        m.show(button2, 0, button2.getHeight());
                    }
                });
                JComponent c = Box.createHorizontalBox();
                c.add(button1);
                c.add(button2);
                f.setContentPane(c);
                f.pack();
                f.setVisible(true);
            }
        ---------- END SOURCE ----------

              serb Sergey Bylokhov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: