Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: interface class ActionListener

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default interface class ActionListener

    The question is as follows: The following is a listing of the interface class actionListener from the Java API:

    package java.awt.events;
     
    import java.util.EventListener;
     
    public interface ActionListener extends EventListener {
     
               public void actionPerformed(ActionEvent e);
     
    }

    Explain the role of this interface in GUI programs written in Java.

    I believe the action listener interface is there for receiving action events. The class that is interested in processing an action event implements this interface, and the object created with that class is registered with a component, using the component's addActionListener method. When the action even occurs, that object actionPerformed method is invoked.

    What more could be said about this?


  2. #2
    Member
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default Re: interface class ActionListener

    What more needs to be said? You should probably provide more information about what type of information you are looking for.

    If you are just looking to fill space for a homework assignment or something, you could probably mention that it is sometimes implemented as an anonymous inner class and explain situations where you might do this.
    Last edited by bbr201; August 17th, 2010 at 08:41 AM.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: interface class ActionListener

    You could mention the theory of abstraction and polymorphism (this is the whole reason there are interfaces). If you want to get into more detail, you can even try to explain why Java chose to use single inheritance + interfaces instead of multiple inheritance (not really pertenant to ActionListener in particular, but rather towards all interfaces).

Similar Threads

  1. ActionListener help
    By QBird in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2011, 11:25 AM
  2. Construct a class that implement ActionListener with no constructor
    By striko_514 in forum Java Theory & Questions
    Replies: 1
    Last Post: July 5th, 2010, 03:15 PM
  3. ActionListener Help?
    By Drag01 in forum AWT / Java Swing
    Replies: 1
    Last Post: March 30th, 2010, 08:21 PM
  4. what is the use of transient class and serializable interface?
    By chinni in forum Object Oriented Programming
    Replies: 3
    Last Post: October 28th, 2009, 05:48 PM
  5. SOMEONE PLEASE HELP ME ADD THE ACTIONLISTENER INTERFACE...
    By beginning2Understand in forum AWT / Java Swing
    Replies: 5
    Last Post: June 30th, 2009, 12:42 AM