Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
jvx:reference [2020/06/24 15:38]
cduncan [Terminology]
jvx:reference [2020/06/24 15:42]
cduncan [Method references]
Line 1769: Line 1769:
 Within the [[https://​sourceforge.net/​projects/​jvx/​|JVx]] framework, every event property of an object starts with the prefix “event” to make it easily searchable and identifiable. But enough dry talk, let’s get started. Within the [[https://​sourceforge.net/​projects/​jvx/​|JVx]] framework, every event property of an object starts with the prefix “event” to make it easily searchable and identifiable. But enough dry talk, let’s get started.
  
-===== Attaching ​listeners ​=====+===== Attaching ​Listeners ​=====
  
 We will now look at all the ways on how to attach a listener to an event. We will now look at all the ways on how to attach a listener to an event.
Line 1775: Line 1775:
 ==== Class ==== ==== Class ====
  
-The easiest way to get notified of events is to attach a class (which is implementing the listener interface) to an event as listener, like this:+The easiest way to get notified of events is to attach a class (that is implementing the listener interface) to an event as listener, like this:
  
 <code java> <code java>
Line 1800: Line 1800:
 } }
 </​code>​ </​code>​
-==== Inlined ​class ====+==== Inlined ​Class ====
  
-Of course we can inline this listener class:+Of coursewe can inline this listener class:
  
 <code java> <code java>
Line 1825: Line 1825:
 } }
 </​code>​ </​code>​
-==== JVx style ====+==== JVx Style ====
  
-So far, so normalBut in [[https://​sourceforge.net/​projects/​jvx/​|JVx]] we have support to attach listeners based on reflection, like this:+So far, so goodHowever, ​in [[https://​sourceforge.net/​projects/​jvx/​|JVx]] we have support to attach listeners based on reflection, like this:
  
 <code java> <code java>
Line 1849: Line 1849:
 } }
 </​code>​ </​code>​
-What is happening here is that, internally, a listener is created ​which references the given object and the named method. This allows to easily add and remove listeners from events and keeping ​the classes clean by allowing to have all related event listeners in one place and without additional class definitions.+What is happening here is that, internally, a listener is created ​that  ​references the given object and the named method. This allows ​us to easily add and remove listeners from events and keeps the classes clean by allowing ​us to have all related event listeners in one place without additional class definitions.
  
 ==== Lambdas ==== ==== Lambdas ====
  
-Yet there is more, we can of course attach [[https://​docs.oracle.com/​javase/​tutorial/​java/​javaOO/​lambdaexpressions.html|lambdas]] to the events as listenerstoo:+Yet there is more. We canof courseattach [[https://​docs.oracle.com/​javase/​tutorial/​java/​javaOO/​lambdaexpressions.html|lambdas]] to the events as listeners too:
  
 <code java> <code java>
Line 1870: Line 1870:
 } }
 </​code>​ </​code>​
-==== Method ​references ​====+==== Method ​References ​====
  
-And last but not least, thanks to the new capabilities of Java 1.8, we can also use [[https://​docs.oracle.com/​javase/​tutorial/​java/​javaOO/​methodreferences.html|method references]]:​+Lastly, thanks to the new capabilities of Java 1.8, we can also use [[https://​docs.oracle.com/​javase/​tutorial/​java/​javaOO/​methodreferences.html|method references]]:​
  
 <code java> <code java>
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information