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

JPopupMenu behaves incorrectly with invoker being set to null

XMLWordPrintable

    • b92
    • generic, x86
    • generic, windows_xp

        Run the following test (it is also attached to the bug report):

        ---- BEGIN OF SOURCE CODE ----

        import java.awt.*;
        import java.awt.event.*;

        import javax.swing.*;

        public class NullInvoker
        {
          public static void main(String[] args)
          {
            final JFrame f = new JFrame("F");
            f.setBounds(100, 100, 100, 100);
            JButton b = new JButton("B");
            b.addActionListener(new ActionListener()
            {
              public void actionPerformed(ActionEvent e)
              {
                JPopupMenu p = new JPopupMenu();
                p.add(new JMenuItem("Item1"));
                p.add(new JMenuItem("Item2"));
                p.add(new JMenuItem("Item3"));
                // uncomment the next line to fix the problem
        // p.setInvoker(f);
                p.setLocation(300, 300);
                p.setVisible(true);
              }
            });
            f.add(b);
            f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            f.setVisible(true);
          }
        }

        ---- END OF SOURCE CODE ----

        When the test starts a frame with a button is shown. Click on the button to show JPopupMenu. It is not clickable and doesn't track any mouse move events to selected the proper menu item. After any item is clicked, popup is not closed.

              alexp Alexander Potochkin (Inactive)
              art Artem Ananiev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: