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

MenuItem ActionEvent's command name is not right

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1
    • 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();
              }
                      
      }

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: