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

Popup menu items don't generate events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 1.4.1_01
    • client-libs
    • generic
    • linux

      This bug was originally submitted with id #4394847.
      The customer still claims it has not been actually fixed.
      Below is the customer's input:

      ===============================================================================

      <...skipped...>

      The problem is that the MenuItem's in the PopupMenu never receive
      events. The problem exists on Linux, and it does not exist on Windows
      2000. I have not tested Windows XP nor Solaris.

      I have been testing on a SuSE 8.0 system, running a 2.4.19 kernel.
      Here is the version information for the SDK:

      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode).

      I have tested on the following window managers/desktops:
      sawfish (for gnome),
      metacity (for gnome2),
      KDE 3.0.5,
      WindowMaker,
      icewm,
      twm,
      fvwm.

      The problem exists for all mentioned window managers/desktops.

      There are many other bugs which I believe are related:

      4073787
      4045826
      4025947
      4053735
      4031436

      Thanks for you time and let me know what you find.

      Best,
      David Lazanja
      ===============================================================================

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

      public class PopupBug extends Frame {
          private PopupBugCanvas fpc;

          public PopupBug() {
      fpc = new PopupBugCanvas();

      add(fpc);

      /*
      ScrollPane pane = new ScrollPane();
      pane.setSize(400,400);
      pane.add(fpc);
      add(pane);
      */
          }

          public static void main(String[] args) {
      PopupBug fp = new PopupBug();

      fp.pack();
      fp.show();
          }
      }

      class PopupBugCanvas extends Canvas implements ActionListener {
          public PopupMenu popup;

          public PopupBugCanvas() {
      enableEvents(AWTEvent.MOUSE_EVENT_MASK);

      setSize(200,200);

      String[] labels =
      new String[] {
      "Test Button 1",
      "Test Button 2"
      };

      String[] commands =
      new String[] {
      "c1",
      "c2"
      };

      popup = new PopupMenu();

      int i;

      MenuItem mi = new MenuItem(labels[0]);
      mi.setActionCommand(commands[0]);
      mi.addActionListener(this);
      popup.add(mi);

      mi = new MenuItem(labels[1]);
      mi.setActionCommand(commands[1]);
      mi.addActionListener(this);
      popup.add(mi);

      this.add(popup);
          }

          public void paint(Graphics g) {
      Color cl = new Color(0xff,0,0);

      setBackground(cl);
      g.drawString("right click", 20, 20);
          }

          public void processMouseEvent(MouseEvent e) {
              if (e.isPopupTrigger()) {
                  popup.show(this, e.getX(), e.getY());
              }
              else if (e.getID() == MouseEvent.MOUSE_PRESSED) {
                  System.err.println("In mouse_pressed");
              }
              else super.processMouseEvent(e);
          }

          public void actionPerformed(ActionEvent e) {
              String command = e.getActionCommand();
              System.err.println("command = "+command+"\n");

              if (command.equals("c1")) {
      System.err.println("command 1\n");
      }
              else if (command.equals("c2")) {
      System.err.println("command 2\n");
      }
      else
      System.err.println("default command");
          }
      }


      ===============================================================================

      I have also verified that bug exists under Linux w/Gnome desktop.
      I did some initial evaluation that I've put into the comments section.


      ###@###.### 2003-01-28

            prssunw Prs Prs (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: