added a start of a work around for KT-1752 not being implemented yet so folks can write nicer swing programs

This commit is contained in:
James Strachan
2012-04-10 10:33:10 +01:00
parent c3b3e5c7c1
commit 686924b919
6 changed files with 219 additions and 10 deletions
@@ -0,0 +1,19 @@
package kotlin.beans
import java.beans.*
// TODO this file may be deleted when this issue is implemented
// http://youtrack.jetbrains.com/issue/KT-1752
/**
* Creates a [[PropertyChangeListener]] for the given function for processing each [[PropertyChangeEvent]]
*/
inline fun propertyChangeListener(fn: (PropertyChangeEvent) -> Unit): PropertyChangeListener = FunctionPropertyChangeListener(fn)
private class FunctionPropertyChangeListener(val fn: (PropertyChangeEvent) -> Unit) : PropertyChangeListener {
public override fun propertyChange(e: PropertyChangeEvent?) {
if (e != null) {
(fn)(e)
}
}
}