简体   繁体   中英

3rd Party Jar Exiting my Program?

Ok, so recently I made a program like snipping tool in java using swing that allows you to select an area of you screen and save it as an image to you computer.

Now, what I am trying to do is make a brand new project that uses the other program i made.

However, when the 3rd party jar is launched in my new app, it works fine, but when i close the 3rd party app it also closes my new app. I do use system exit in the 3rd part app which I know is the reason it is closing everything.

Now my question is: is it wrong to use system exit for that reason? Is there something I can do to prevent closing my new app without modifying the old one?

Or, could you give suggestions in the future instead of using system.exit because I still want the original one to be able to close properly, i just don't want my new one that uses the old jar to close as well.

I have tried disabling system exit in my new app which just creates more problems.

Don't use System.exit();

Is there something I can do to prevent closing my new app without modifying the old one?

use:

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

if the frame is the only window open it will exit the JVM. If other Windows are open only the current Window is closed. The default close operation is used when you click on the "Close" button of the Window.

Better yet, don't use a JFrame as the Window for your tool. Instead you should use a JDialog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM