We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I'm currently making a text editor using processing. I recently added the ability to run processing code directly from the text editor. But I have no control over the program that opens when you compile and run it using the exec() function. Is there any way to control other java applications? I'm asking this on the processing forum because I used the processing compiler to run the code, but if you have any java suggestions feel free to tell me.
Answers
Your intentions is to control the program that you just started executing? Something like stop executing or re-run it again, exactly as what the PDE does?
Kf
Yes, I want a similar thing to what processing does to its sketches. I want to be able to stop a sketch and know when a sketch is active.
A bit convoluted but this provides some insight:
https://github.com/processing/processing/blob/master/java/src/processing/mode/java/JavaEditor.java#L1129
This is only looking at the java mode. Notice that rebuilding the skecth calls handleStop() in case the window is alive.
Another lead is
internalCloseRunner()
which is implemented by the JavaEditor object which extends the Editor object which by definition it is mandated to implement this function. This is more info that what you might need. Check for example: https://github.com/processing/processing/blob/master/app/src/processing/app/ui/Editor.java#L2802In other words, Processing keeps an eye on the current running app associated to the current editor (yes, you could have multiple editor windows open): https://github.com/processing/processing/blob/master/java/src/processing/mode/java/JavaEditor.java#L1099
I am presenting this from the perspective of Processing i.e. based on their design. Can you do it using some java mechanism? I dunno... you should provide the code you are using to launch your "code" from the text editor.
Kf
The code I use to run the file is very simple:
this just get's activated whenever someone presses CTRL + R (just like in the processing editor).
I'll look into your answer, thanks for all the info!