Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking saved or not

 
ashok kandaswamy
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic