How to save application options before exit?

前端 未结 4 2006
一个人的身影
一个人的身影 2020-12-13 05:01

I have made an application and i need to save some options before exit.(something like window dimension, ..., that will be written in a file.)

The main frame has set

4条回答
  •  渐次进展
    2020-12-13 05:40

    Not sure this applies to your situation, but it may to others who surf to this thread. My application has a main() and at the end has the while (!shell.isDisposed) loop. When the application runs that loop is going, and when the app is closed that loop ends and it drops to what ever is after it in the main method. This is where I put a check for if the editor is dirty and if the preferences have changed and handle those to conditions. My method attached to the file close disposes the shell and calls the closeCurrent() method but if someone clicks the 'x' close window icon it falls to here and I check again if anything is dirty and save if I need to.

    while (!shlCpbtool.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        // exit
        if(dirty){
            closeCurrent();
        }
    

提交回复
热议问题