Subscribing to events

You are browsing legacy Javonet 1.5 (Java<>.NET bridge for Windows) documentation. Use the left side menu or click here to switch to latest Javonet 2.0 documentation. Javonet 2.0 allows you to use any module from JVM, CLR, Netcore, Python, Ruby, Perl, NodeJS on Windows, Linux and MacOs from any application created in Java, Clojure, Groovy, Kotlin, C#, F#, J#, VB.NET, Python, Perl, Ruby, JavaScript, TypeScript, C++ and GoLang

Subscribe to any .NET event with Javonet. Event subscription works the same way as listening Java events. The performance of event subscription is extremely high and allows you to interact with .NET code like it was native Java code. When the event occurs, your Java listener callback is called in a separate thread.
The simplest way to subscribe an event is to use an anonymous Java class.

Assuming we have a custom any runtime with the following class inside:

Select technology of module you want to use:

The anonymous class should implement special INEventListener interface to subscribe to .NET event.

I code in:

Select technology of module you want to use:

Using .NET standard library elements

To create a .NET button and listen for a "Click" event:

I code in:

Select technology of module you want to use:

The anonymous class should implement special INEventListener interface. Alternatively you can write a separate class as the event listener by extending NEventListener and overriding the eventOccurred method, or by implementing the ((INEventListener)) interface.

I code in:

Select technology of module you want to use:

Usage of your listener class:

I code in:

Select technology of module you want to use:

See Live Example!