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

Consider adding Action factory method to AbstractAction

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      I had a ActionListener that I wanted to use within an ActionMap, which requires an Action. I had to subclass AbstractAction to put it in the ActionMap:
      Action a= new AbstractAction(){
          public void actionPerformed(ActionEvent e){
              ActionListenerThing.actionPerformed(e);
          }
      };

      Considering the simplicity of subclassing this, would it not be easier for the user in this situation to have a factory method that does all this for the user:
      Action a = AbstractAction.createAction(ActionListenerThing, null, null);

      public static AbstractAction createAction(ActionListener listener, String name, Icon icon){....}






      JUSTIFICATION :
      would make wrapping an ActionListener easier, it seems a good fit in that both are ActionListeners.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      easy to wrap and ActionListener in an AbstractAction
      ACTUAL -
      must subclass when a wrapper could easily be used.

      ---------- BEGIN SOURCE ----------
      look at JDK source of AbstractAction, there is no wrapper method.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      subclass AbstractAction

            svioletsunw Scott Violet (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: