This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi , i am developing one smart word processor in java siwng,for load and save operation am using filechossers.
i am supporting multiple documents also using tabbedpane.i want to do when typing something on the document and without save that we will close the application means i want to do the save operation here.
(class field) boolean dirtyData = false; - add a document listener to the doc - it's job is to make dirtyData = true; - in your save() method, include dirtyData = false; - set the default close operation of the frame to DO_NOTHING_ON_CLOSE - add a windowListener to the frame, and in windowClosing() check if dirtyData is true, if so, call save() (or ask user if save() wanted), then System.exit(0);
there was a recent-ish thread on this subject (past 4-6 weeks), with other options. a quick search of this forum should find it.