MenuItem ActionEvent's command name is not right

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P2
    • None
    • Affects Version/s: 1.1
    • Component/s: client-libs
    • None
    • x86
    • windows_95



      Name: el35337 Date: 01/09/97

      MenuItem ActionEvent's command name is not the same as the
      one set by setActionCommand


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

      public class MenuItemCmdBug extends Frame implements ActionListener{
              TextArea ta;
              public MenuItemCmdBug(){
                      super();

                      MenuBar menubar = new MenuBar();
                      setMenuBar(menubar);

                      Menu test = new Menu("Test");
                      menubar.add(test);
                      MenuItem bug = new MenuItem("Caption");
                      bug.setActionCommand("Command");
                      bug.addActionListener(this);
                      test.add(bug);

                      ta = new TextArea();
                      add("Center",ta);
              }

              public void actionPerformed(ActionEvent e){
                      ta.append("The real command string is set as \"Command\" but\n");
                      ta.append("getActionCommand() is \"" + e.getActionCommand() + "\"\n");
              }

              public static void main(String[] args){
                      MenuItemCmdBug bug = new MenuItemCmdBug();
                      bug.resize(600,600);
                      bug.show();
              }
                      
      }

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

            Assignee:
            Anne Fowler (Inactive)
            Reporter:
            Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: