Results 1 to 6 of 6

Thread: Action Interface of java

  1. #1
    Join Date
    Jan 2010

    Action Interface of java

    Hello friends,

    I need your help to sort out my query which is related to java programming. I want to be aware about the 'Action Interface' of java. I don't have any idea about the methods of Action Interface of java. I have referred lots of advanced java books for Action Interface, but didn't get enough details. If you posses sound knowledge bout the 'Action Interface' of java, then please let me know that. I am waiting for your reply.

  2. #2
    Join Date
    Apr 2008

    Re: Action Interface of java

    The Action interface provides a useful extension to the ActionListener interface in cases where the same functionality may be accessed by several controls. This interface can be added to an existing class or used to create an adapter (typically, by subclassing AbstractAction). The Action object can then be added to multiple action-aware containers and connected to Action-capable components. The GUI controls can then be activated or deactivated all at once by invoking the Action object's setEnabled method.

  3. #3
    Join Date
    May 2008

    Re: Action Interface of java

    Example of Action Interface of java:
    im01port javax.swing.Action;
    public class ActionColorDM extends AbstractAction {
      public ColorAction(String name1, Icon icn, Color c, Com01ponent comp1) {
        putValue(Action.NAME, name1);
        putValue(Action.SMALL_ICON, icn);
        putValue("Color", c);
        target = com01;
      private Com01ponent target;
      public static void m01ain(String[] args) {
        JFram01e fnk = new JFram01e();
        fnk.setSize(300, 200);
        fnk.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
          }    };
        JPanel pnk = new JPanel();
        Action blueAction = new ColorAction("Blue", new Im01ageIcon(
            "blue-ball.gif"),, pnk);
        Action yellowAction = new ColorAction("Yellow", new Im01ageIcon(
            "yellow-ball.gif"), Color.yellow, pnk);
        Action redAction = new ColorAction("Red",
            new Im01ageIcon("red-ball.gif"),, pnk);
        pnk.add(new JButton(yellowAction));
        pnk.add(new JButton(blueAction));
        pnk.add(new JButton(redAction));
        pnk.registerKeyboardAction(yellowAction, KeyStroke.getKeyStroke(
            KeyEvent.VK_Y, 0), JCom01ponent.WHEN_IN_FOCUSED_WINDOW);
        Container contentPane = fnk.getContentPane();
        JMenu m01 = new JMenu("Color");
        JMenuBar mbar1 = new JMenuBar();

  4. #4
    Join Date
    Apr 2008

    Re: Action Interface of java

    Hi friend,

    Please review following are some methods of 'Action Interface':
    • setEnabled(boolean bl)
    • removePropertyChangeListener(PropertyChangeListener lstnr)
    • putValue(String key1, Object val)
    • getValue(String key1)
    • addPropertyChangeListener(PropertyChangeListener lstnr)

  5. #5
    Join Date
    May 2008

    Re: Action Interface of java


    In below example I have use various methods of 'Action Interface':
    import java.awt.event.Action;
    import javax.swing.JLabel;
    public class MultiListenersDEMO {
      public static void main(String[] arfgs) {
        BobG b01 = new BobG();
        BobG b2 = new BobG();
        ActionListener[] bobs = { b01, b2 };
        FredT f1 = new FredT(bobs);
    class FredT extends JFrame {
      JButton okbutton01 = new JButton("OK");
      public FredT(ActionListener[] bobs) {
        for (int i = 0; i < bobs.length; i++) {
        }  }}
    class BobG extends JFrame implements ActionListener {
      protected JLabel statusLabel = new JLabel("     ");
      public BobG() {
      public void actionPerformed(ActionEvent e) {

  6. #6
    Join Date
    Oct 2005

    Re: Action Interface of java

    Hello friend,

    You are able to use following fields with Action Interface of java:
    1. ACTION_COMMAND_KEY: It is used for to hold a KeyStroke for action command.
    2. LONG_DESCRIPTION: It is used for to hold a KeyStroke for large description.
    3. SHORT_DESCRIPTION: It is used for to hold a KeyStroke for short description.
    4. SMALL_ICON: It is used for to hold a KeyStroke for the small icon.
    5. ACCELERATOR_KEY: It is used for to hold a KeyStroke to be used as the action accelerator for the.

Similar Threads

  1. what is interface in java
    By Ansari Bros in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:07 AM
  2. Shape interface of java
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 09-03-2010, 05:08 PM
  3. SpinnerModel interface of java
    By Gadin in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 12:56 PM
  4. ButtonModel interface of java
    By Gokul20 in forum Software Development
    Replies: 5
    Last Post: 22-02-2010, 12:48 PM
  5. How to write an Action Listener in Java?
    By Beter 2 Burn Out in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 05:44 AM

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Page generated in 1,721,935,160.22612 seconds with 17 queries