Results 1 to 2 of 2
  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    10

    Default Multiple listeners per event

    One event can have multiple listeners as shown in the example below:

    Java Code:
    public class BeepFiveApplet extends Applet  {
      
       public void init () {
       
         // Construct the button
         Button beep = new Button("Beep");
    
         // add the button to the layout
         this.add(beep);
    
         // specify that action events sent by this
         // button should be handled by a new BeepAction object
         beep.addActionListener(new BeepAction());
         beep.addActionListener(new BeepAction());
         beep.addActionListener(new BeepAction());
         beep.addActionListener(new BeepAction());
         beep.addActionListener(new BeepAction());
      
       }
    }

  2. #2
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    8

    Default Why?

    Hello.

    Can you please explain why one would need multiple ActionListeners on the same component. For me, it would make more sense if you add different types of event listeners.

    Thanks for the Tip! ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

Similar Threads

  1. MouseDragged Event
    By Preethi in forum New To Java
    Replies: 1
    Last Post: 03-04-2008, 06:09 AM
  2. Event
    By nt5515 in forum New To Java
    Replies: 0
    Last Post: 02-15-2008, 05:44 PM
  3. Listener for SWT event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 10:04 AM
  4. SWT Event Handling
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-30-2007, 01:21 PM
  5. Action Event and Listeners
    By lost1 in forum New To Java
    Replies: 3
    Last Post: 11-14-2007, 05:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •