Reputation: 2148
I am creating an IDE using swing which can compile and run user's program. if user write swing program and run the program which have frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
inside that program, it successfully run. but when user close there program, my IDE also get closed. How to get rid from this. I want that my IDE don't get closed.
Is there any procedure that my swing application still get running when user close there program?
For Example: in Netbeans IDE, when we run a swing program and close that program, Netbeans IDE does not get closed.
Upvotes: 0
Views: 64
Reputation: 285405
You could change their close operation to something else such as DISPOSE_ON_CLOSE or DO_NOTHING_ON_CLOSE.
i.e.,
OtherGUI otherGui = new OtherGui();
otherGui.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
otherGui.setVisible(true);
As an aside, you might want to tell us more about your current design of running other programs, as that makes me worry about possible issues. What exactly are you doing?
Edit
You state:
actually i am running that program via reflection and i don't have right to change user program, so what should i do in such case?
and
I am creating an IDE using swing which can compile and run user's program. if user write swing program and run the program which have frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inside that program, it successfully run. but when user close there program, my IDE also get closed. How to get rid from this. I want that my IDE don't get closed.
I've no experience with this, but I suspect that you will want to create each launched GUI in its own JVM, which you'd do not with reflection (I don't think), but by creating a new process with a ProcessBuilder, taking care to handle all streams appropriately, and calling Java directly in your process, launching the program.
Upvotes: 2