aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Checking saved or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Checking saved or not" Watch "Checking saved or not" New topic
Author

Checking saved or not

ashok kandaswamy
Greenhorn

Joined: Aug 19, 2008
Posts: 16
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.

please help very urgent,

thanks in advance.
by
ashok


Sk.Ashokkumar.....
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> i am supporting multiple documents

depends on how many 'multiple' is.

here's a basic scenario for a single doc:

(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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checking saved or not
 
Similar Threads
save as text
How to save a file in default format
How to validate JFileChooser path ??
capture image
Menu Events