This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when to use ActionListener interface

 
abhay jain
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when to use ActionListener interface in a program , i am confused after watching to many interfaces , please help
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use ActionListener when
1) You got components which are capable of triggering action events
2) You are interested in receiving such events

e.g. JButton is capable of triggering action event (since it has the addActionListener() method) If you want to get notified when a particular button is pressed you would use an action listener
 
abhay jain
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks maneesh

can we also use MouseListener (in case of JButton and mouse event on it ) in place of ActionListener
if yes then what will be pros and cons of it
if no then please tell me ....why ?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a MouseListener if you're interested in responding to mouse events. Usually you don't want that on a JButton, because "pressing" a button is more complicated than just clicking on it. For instance, you can activate it using the keyboard.
 
abhay jain
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Matthew
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at this section in the Java™ Tutorials.

This looks like a Swing/AWT related question, so I shall move this discussion to our GUIs forum.
 
abhay jain
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great ....... thanks a lot Campbell Ritchie
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic