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

cannot close a JPopupMenu by clicking on a disabled component

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.4.0
    • client-libs
    • x86
    • windows_nt

    Description



      Name: mt13159 Date: 08/14/2001


      If a JPopupMenu is visible you cannot close it if you click on
      a disabled component. Click on an enabled component will dismiss
      the menu. Clicking on a disabled component dismisses the JPopupMenu
      in JDK 1.1.8, JDK 1.2.2, and JDK 1.3.1. It does not work in
      JDK 1.4 build 74. Run the following test case:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      public class PopupTest extends JFrame
      {
          public static void main(String[] args)
          {
              PopupTest t = new PopupTest();
              t.setSize(320,240);
              t.setVisible(true);
          }

          public PopupTest()
          {
              addWindowListener(new WindowAdapter()
              {
                  public void windowClosing(WindowEvent e)
                  {
                      System.exit(0);
                  }
              });

              getContentPane().setLayout(new BorderLayout());
              JPanel p = new JPanel(new BorderLayout());
              getContentPane().add(BorderLayout.CENTER, p);

              JButton b = new JButton("step 1: press me to display menu");
              b.addActionListener(new ActionListener()
              {
                  public void actionPerformed(ActionEvent e)
                  {
                      JPopupMenu m = new JPopupMenu();
                      m.add(new JMenuItem("item 1"));
                      m.add(new JMenuItem("item 2"));
                      m.add(new JMenuItem("item 3"));
                      m.add(new JMenuItem("item 4"));
                      m.add(new JMenuItem("item 5"));
                      m.add(new JMenuItem("item 6"));
                      m.show((Component)e.getSource(), 0, 10);
                  }
              });


              JLabel disabled = new JLabel("step 2: click me and notice menu is not dismissed");
              disabled.setEnabled(false);

              JLabel enabled = new JLabel("step 3: click me and notice menu is dismissed");

              p.add(BorderLayout.NORTH, b);
              p.add(BorderLayout.CENTER, disabled);
              p.add(BorderLayout.SOUTH, enabled);
          }
      }
      (Review ID: 129568)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              rraysunw Richard Ray (Inactive)
              mthakore Mayank Thakore (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: