# ActionListener Usage

**URL:** <https://forum.kirupa.com/t/actionlistener-usage/263043>\
**Category:** Uncategorized\
**Created:** [June 12, 2008, 3:30am UTC](https://forum.kirupa.com/t/actionlistener-usage/263043 "2008-06-12T03:30:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polaris](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Polaris](https://forum.kirupa.com/u/Polaris)\
**Post date:** [June 12, 2008, 3:30am UTC](https://forum.kirupa.com/t/actionlistener-usage/263043/1 "2008-06-12T03:30:54Z")

</div>

**[FONT=Verdana][SIZE=4]How do I properly use a ActionListener in JAVA to have a trafficlight be able to turn each light on and off?[/SIZE][/FONT]**

```
               [FONT=Verdana][SIZE=4]I have a homework assignment that I need to make a traffic light that is turned on using buttons. I have everything done except linking the buttons to the lights. Any help would be great. Thanks.[/SIZE][/FONT]
```

---

<div class="post-metadata">

**Author:** ![Polaris](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Polaris](https://forum.kirupa.com/u/Polaris)\
**Post date:** [June 12, 2008, 5:39am UTC](https://forum.kirupa.com/t/actionlistener-usage/263043/2 "2008-06-12T05:39:09Z")

</div>

Okay, I’ve got the buttons working, but its not too effective, I have four buttons, red, yellow, green, and a ‘test’ button which turns all the lights on. Is there a way to use a listener for multiple buttons, because the one i am using now really is only good for 2 buttons as opposed to 4.
