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

ActionEvent.getActionCommand() returns null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs

      A JButton is created with the text "Run". I'm expecting the ActionEvent.getActionCommand() to return this text. Instead it is returning null :

      java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=null] on com.sun.java.swing.JButton[,7,7,66x58,layout=com.sun.java.swing.OverlayLayout]

      To reproduce run the Java2D demo at :

      /usr/local/java/jdk1.2fcs/solaris/demo/jfc/Java2D

      Select the Options menu and the Run Window menuitem. And then select the Run button. Nothing happens because e.getActionCommand() returns null.

          public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand() == "Run") {
                  runB.setText("Stop");
                  runB.setBackground(Color.red);
                  start();
              } else if (e.getActionCommand() == "Stop") {
                  stop();
              }
          }


      java full version "JDK-1.2fcs-B"

            gsaab Georges Saab
            blichtensunw Brian Lichtenwalter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: