Results 1 to 5 of 5

Thread: How to use Actions in Java?

  1. #1
    Join Date
    Aug 2006

    How to use Actions in Java?

    Hi friends,
    I have recently started doing java, so i am not having much knowledge about it. I have created an application in which i need to do the coding of the action. But i don't know anything about it. So i thought that posting here might help me.!! Can someone explain me how to use Actions in Java.?? Any coding related to the topic would be grateful.
    AMD Sempron 2800+ @ 2Ghz
    Asus A7V8X-LA
    120Gb Seagate barracuda 7200Rpm Ultra-ATA 100
    Elixir 512mb DDR Pc3200 (Soon 1Gb)
    Club 3D Radeon 9600 256Mb
    Lite-On Cd & Dvd writer combo
    IDE-Dvd drive
    400w Psu
    Windows Xp Pro Sp2
    Advent Wireless Mouse & Keyboard.

  2. #2
    Join Date
    Jul 2006

    Re: How to use Actions in Java?

    If you are having two or more components which are performing the same function then you can use an Action object to implement the function. An Action can be used to separate functionality and state from a component. An Action object is an ActionListener that provides action-event handling. Along with that it provides handling of the text, icon and the buttons also. The state that an action can handle includes text, icon, mnemonic, enabled, and selected status.
    Signatures reduce available bandwidth

  3. #3
    Join Date
    Mar 2008

    Re: How to use Actions in Java?

    For attaching an action to a component, you will have to use the setAction method. The following things happen when you invoke setAction on a component :
    • The component's state is updated to match the state of the Action.
    • The component's state is updated to match the Action, if the state of the Action changes.
    • The Action object is registered as an action listener on the component.

  4. #4
    Join Date
    Feb 2008

    Re: How to use Actions in Java?

    The following snippet of coding is an example of creating a tool-bar button and menu item :
    Action leftAction = new LeftAction(); 
    button = new JButton(leftAction)
    menuItem = new JMenuItem(leftAction);

  5. #5
    Join Date
    Apr 2008

    Re: How to use Actions in Java?

    The following example can be used for creating and instantiating an AbstractAction subclass :
    leftAction = new LeftAction("Take left", anIcon,
                 "This is the left button.",
                 new Integer(KeyEvent.VK_L));
    class LeftAction extends AbstractAction {
        public LeftAction(String text, ImageIcon icon,
                          String desc, Integer mnemonic) {
            super(text, icon);
            putValue(SHORT_DESCRIPTION, desc);
            putValue(MNEMONIC_KEY, mnemonic);
        public void actionPerformed(ActionEvent e) {
            displayResult("Action for first button/menu item", e);

Similar Threads

  1. Beyond compare 3 doing actions without asking user
    By pele1200 in forum Windows Software
    Replies: 3
    Last Post: 13-08-2012, 01:31 PM
  2. how to use voice actions on Ice cream Sandwich
    By Popeyee in forum Portable Devices
    Replies: 9
    Last Post: 14-12-2011, 02:24 PM
  3. Several buttons doing the same actions on different controls
    By AbhayD in forum Software Development
    Replies: 4
    Last Post: 11-12-2009, 09:28 PM
  4. Multiple actions of a form
    By Sadiee in forum Software Development
    Replies: 3
    Last Post: 29-06-2009, 07:14 PM
  5. Actions depending on the length of the press of a button
    By Elijah in forum Software Development
    Replies: 3
    Last Post: 16-03-2009, 10:40 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,716,622,455.85430 seconds with 17 queries