I could not find any answer related to this question. I wonder if it is possible. Here is my problem.
I have a core processing application written in Fortran. The application needs a new UI. The Fortran code has its own main loop. It communicates
with the UI through a interface routine. This routine calls the main event loop of
whatever UI library that its used, for example the current UI is Motif. So it calls
the Motif main event loop. I would like to replace Motif with Java swing. I could not find thing on Java main event loop. My questions are
1) Is it possible to call Java main loop directly ?
2) I know it possible for Java to call another language. How can another language call a Java routines ?
-------------- Additional comments
It looks like it might not be possible to do this, at least not the way I envision it. Here is an algorithm that I try to use
do loop until terminate
do some internal processing
1 check ui event queue
if queue has event
2 call ui event dispatcher for all UI events
end loop
what I like to know, is there any kind of routine to replace #1 and #2. I was hoping Java has something like EventQueue.hasEvent ();
EventQueue.dispatchEvent (event);
From the comments so far, it does not look like there is such a thing.
SwingUtilities.invokeAndWait() and invokeLater()No, you cannot call the GUI main event loop directly; however, you can submit items to the main event loop to eventually be ran on its Thread.
The main event loop does a lot of things inside the GUI, some of those things are scheduling the graphics to be drawn, accepting input, etc. It's a design choice, and Java went with a multi-threading model where the non-GUI code doesn't run in the GUI event loop. The reasoning behind it is likely due to the GUI loop possibly being paused or corrupted causing GUI performance issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With