Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Event Binding in Java ?

 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was wondering if we can somehow bind a set of Java events with the occurrence of a particular event?

For example, if a list item gets selected / or if a radio button gets selected, we want to perform a number of operations. One way is to take care of all the events (through listeners) that could selected the item and/or radio button.
The other more sophisticated way can be binding of the desired operations with the selection of the component. So that, once desired operations are implemented and registered with the (say) component's selection event, the programmer need not to worry any more.

There must be some binding mechanism in Java.

Hope that I am able to explain what I am looking for.
Thanks in advance.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thinks you're looking for javax.swing.Action / AbstractAction
 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for pointing in to right direction.
However, javax.swing.Action is limited to several Components.
Can you suggest something similar for JList and/or other components.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through the documentation for those Components etc, and you will find methods called addXXXListener. Those methods tell you which Listeners are considered appropriate to those classes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic