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

MenuItem.enableEvents does not work

XMLWordPrintable

    • x86
    • windows_95



      Name: diC59631 Date: 11/21/97


      1. Create a Frame, attach a MenuBar. Create a Menu
      and attach it to the menu bar. Create a MenuItem
      and attach it to the menu. The Menu and MenuItem
      are actually instances of sub-classes of Menu
      and MenuItem which call enableEvents(AWTEvent.
      ACTION_EVENT_MASK) in the constructor. They also
      override processActionEvent to print a diagnostic
      message verifying that processActionEvent was
      called.
      When the class is executed and the menu item is
      selected, processActionEvent is not called
      2. Source code
      ---BEGIN HERE-------------------------------------
      import java.awt.*;
      import java.awt.event.*;

      class _Menu extends Menu
      {
          public _Menu (String text)
          {
              super(text);
              enableEvents(AWTEvent.ACTION_EVENT_MASK);
          }

          protected void processActionEvent (ActionEvent e)
          {
              System.out.println("_Menu: action event");
              super.processActionEvent(e);
          }
      }

      class _MenuItem extends MenuItem
      {
          public _MenuItem (String text)
          {
              super(text);
              enableEvents(AWTEvent.ACTION_EVENT_MASK);
          }

          protected void processActionEvent (ActionEvent e)
          {
              System.out.println("_MenuItem: action event");
              super.processActionEvent(e);
          }
      }

      public class MENUBUG
      {
          public void open ()
          {
              Frame frm = new Frame("MENUBUG");
              frm.setMenuBar(new MenuBar());
              frm.setBounds(204, 152, 396, 300);
              Menu m = new _Menu("Menu");
              MenuBar mb = frm.getMenuBar();
              mb.add(m);
              MenuItem mi = new _MenuItem("menuitem");
              m.add(mi);
              frm.setVisible(true);
          }

          public static void main (String args[]){
              new MENUBUG().open();
          }
      }
      ---END HERE---------------------------------------
      3. Not applicable
      4. Not applicable
      5. Not applicable
      (Review ID: 20695)
      ======================================================================

            rramsunw Ranganathan Ram (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: