Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ActionPerformed and ActionListener on Netbeans are the same?  RSS feed

 
Federico Techera
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActionPerformed and ActionListener on Netbeans


Hello, If I create a ComboBox on Netbeans using GUI design, then I right click over the Combobox I can find Events - Action - ActionPerformed... but I can't find ActionListener...


Are ActionPerformed and ActionListener the same?

or...

where is ActionListener on GUI Netbeans?

Do I need to manualy write the ActionListener part?

Thanks
 
Niraj Jha
Ranch Hand
Posts: 63
Java Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActionListener is an interface containing one method actionPerformed(...).
We generally implements ActionListener and override actionPerformed(...) method.
 
James Harte
Greenhorn
Posts: 17
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to talk about ActionListener and actionPerformed() then you need to first consider ActionEvent.
- ActionEvent is, as the name would imply, an event which has occurred.
- ActionListener is an object which is listening for the event. Please note that ActionListener is an interface which a class may implement.
- actionPerformed(ActionEvent ae) is the action (method) which a listener is going to do when the listener finds out that the event has occurred.

Please note that if you want a listener to listen for a particular event, then you need to have a line similar to the following:
someComponent.addActionListener(instanceOfActionListener);
 
Campbell Ritchie
Sheriff
Posts: 53760
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall move this discussion because we usually discuss such things on the GUIs forum. Have a look at this recent thread about the same topic.
 
Federico Techera
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niraj Jha wrote:ActionListener is an interface containing one method actionPerformed(...).
We generally implements ActionListener and override actionPerformed(...) method.


Understand. Thanks a lot
 
Federico Techera
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Harte wrote:If you are going to talk about ActionListener and actionPerformed() then you need to first consider ActionEvent.
- ActionEvent is, as the name would imply, an event which has occurred.
- ActionListener is an object which is listening for the event. Please note that ActionListener is an interface which a class may implement.
- actionPerformed(ActionEvent ae) is the action (method) which a listener is going to do when the listener finds out that the event has occurred.

Please note that if you want a listener to listen for a particular event, then you need to have a line similar to the following:
someComponent.addActionListener(instanceOfActionListener);


Thanks for the help, now I can move on.
 
Federico Techera
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I shall move this discussion because we usually discuss such things on the GUIs forum. Have a look at this recent thread about the same topic.


Thanks for the link
 
Campbell Ritchie
Sheriff
Posts: 53760
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!