I'm working on a project where we have a Java application that is opening a Chromium popup window using JxBrowser. When the user performs an action on the UI, I want that to send an event back to the Java application with some data. On the UI side I have a method publishing a custom event:
public sendUpdateEvent(): void {
const event: CustomEvent = new CustomEvent('update', {
detail: 'helloworld',
});
document.dispatchEvent(event);
}
And on the Java side we have set up an event listener using JxBrowser functionality.
browser.navigation().on(FrameLoadFinished.class, event -> {
Frame frame = event.frame();
frame.document().ifPresent(document -> {
EventType eventType = EventType.of("update");
document.addEventListener(eventType, myEvent -> {
System.out.println(myEvent.type());
}, false);
This has worked, we've been able to capture the event on the Java side, but the Event interface doesn't seem to give us a way to get the contents of the event? Does anyone know how you could actually read the properties of a custom event like this?