• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

upon close how: saved in a file(JFileChooser) since last modified

 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Upon close an app how determine AND prompt(continue or cancel =prompt), if textfields/textarea (both saved together), SAVED in a file(JFileChooser) since last CHANGED/MODIFIED?

if have normal textarea:
displayArea = new JTextArea(); // create textarea

then I must use:
public DocumentEvent.ElementChange getChange(Element elem)
from DocumentEvent (Java 2 Platform SE v1.4.2 http://72.5.124.55/j2se/1.4.2/docs/api/javax/swing/event/DocumentEvent.html )

for Element put displayTextArea here?

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to keep a flag that indicates whether or not the contents have been modified. In the document listener you set that flag to true, upon saving you set it to false.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I know this, that I do not know is how to compare MODIFIED/SAVED (true) or MODIFIED/NOT-SAVED (false) ? what classes/methods use ?
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a need for modified/saved? In all programs I've seen only two states - modified or unmodified. Saved falls under the last category. It's then simply a matter of using the boolean value:
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yet under test, I get error 1 at:


 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because line 10 is wrong. First of all, there is no method called getChange in interface DocumentEvent.ElementChange. There is one in DocumentEvent, but you still can't treat it as a static method, something you are doing now.

Try adding a DocumentListener to your text area's document (using getDocument().addDocumentListener(...)).
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IF ALSO want to check and textboxes?

There's any complete scriptlet, from ready made open source java program, about this?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Leonidas Savvides wrote:IF ALSO want to check and textboxes?



But no, you are doing it the wrong way. You shouldn't be worrying about whether the user clicks a checkbox. You want to keep track of whether the model changes (that's the data you are updating) -- and not whether the view changes (that's your user interface).

So everywhere in the code where you change the data, set on the "modified" flag.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic