Conflicting Popup Menus

Bugzilla bug #132376

Right click on the applet to view the popup menu. If you right click outside the applet window, the browser popup menu should show. If you right click inside the applet, the applet popup menu should show ("Cut", "Copy" and "Paste").

Bug Behavior:
In Netscape 6.x for Macintosh OS 9 or OS X (with the MRJPlugin), both menus show when you right click on the applet. First, the applet popup menu shows (as expected), then when an item is selected or the menu is otherwise cancelled, the browser popup menu shows (no expected). This occurs whether or not the event is consumed by the applet.
This bug does not occur with Internet Explorer 5.1 on OS X, or any any browser on Windows

If you are using a 1-button mouse, use Ctrl-Click instead of right click.

   

    If you have any insights, workarounds or comments about this test page please contact Mickey Segal.  A listing of  many Macintosh Java bugs with demonstration applets is at this link, including information on how to add any necessary Java plugins.

The source code is shown below:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class PopupMenuTest extends Applet
   implements ActionListener, MouseListener {

   PopupMenu popup;

   public void init() {
      System.out.println("Started applet");
      MenuItem mi;
      Label l1 = new Label("Right-Click or Contrl-Click Here");
      add(l1);
      popup = new PopupMenu("Edit");

      mi = new MenuItem("Cut");
      mi.addActionListener(this);
      popup.add(mi);

      mi = new MenuItem("Copy");
      mi.addActionListener(this);
      popup.add(mi);

      popup.addSeparator();

      mi = new MenuItem("Paste");
      mi.addActionListener(this);
      popup.add(mi);

      addMouseListener(this);
      add(popup); // add popup menu to applet

      enableEvents(AWTEvent.MOUSE_EVENT_MASK);

      resize(200, 200);
      }

   public void paint(Graphics g){
    g.setColor(Color.gray);
    g.fillRect(0,0,200,200);
   }

   public void mouseClicked(MouseEvent e) {
   }

   public void mouseEntered ( MouseEvent e ) {
   }

   public void mouseExited ( MouseEvent e ) {
   }

   public void mousePressed ( MouseEvent e )
   {
      int   input_modifiers = e.getModifiers ( );
      if ((input_modifiers & e.BUTTON3_MASK) != 0 || (input_modifiers & e.BUTTON2_MASK) != 0) {
         popup.show(e.getComponent(), e.getX(), e.getY());
      }
      //super.processMouseEvent(e);
      e.consume();
   }

   public void mouseReleased ( MouseEvent e ) {
   }

   public void actionPerformed(ActionEvent e) {
      String command = e.getActionCommand();

      if (command.equals("Cut")) {
         // perform cut operation
      } else if (command.equals("Copy")) {
         // perform copy operation
      } else if (command.equals("Paste")) {
         // perform paste operation
      }
   }
}