-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.1
-
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();
}
}
======================================================================
- duplicates
-
JDK-4023772 actionCommand property not set properly in action events on menuitems
-
- Closed
-