Question

I am exploring the use of the Guava EventBus in a Swing application and everything works fine so far, with one exception that is related to modal dialogs.

When my application shows a modal JDialog (let's call it dialog1) and events are posted by this dialog, everything is fine, which means that these events are immediately received by subscribers within and outside the modal dialog.

But if my application shows a different modal JDialog (let's call it dialog2), and if this dialog2 creates the aforementioned dialog1 and shows it modally, the events posted by dialog1 are queued up until dialog1 is closed, so that the subscribers do not receive them immediately.

I do not understand why it works fine in the first case but not in the second.

If it would not work in both cases, I would think that it would be caused by the modality blocking other stuff outside the modal dialog. But as the first case works fine and so I am confused.

Any hints would be very appreciated!

Cheers, Christian

Was it helpful?

Solution

It sounds like you're saying that you open a modal dialog (dialog1) in response to an event, and then actions on that dialog post more events to the same EventBus? In that case, this is an issue with how EventBus handles events posted on the same thread while handling another event: it queues them up until handling of the first event completes, to ensure that events are handled strictly in the order they're posted. The model it's using generally assumes that your event handling code won't tie up the thread indefinitely.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top