Skip to main content
offending words removed
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

Problem: our application behaves currently quite silly and allows users to close a form window after certain changes without any confirmation, instead of pressing the Save button. This makes them complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Problem: our application behaves currently quite silly and allows users to close a form window instead of pressing the Save button. This makes them complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Problem: our application allows users to close a form window after certain changes without any confirmation, instead of pressing the Save button. This makes them complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Changed the offending sentence, will hopefully save this question a few downvotes.
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

Problem: our users are beingapplication behaves currently quite silly and allows users to close a form window instead of pressing the Save button. TheyThis makes them complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Problem: our users are being silly and close a form window instead of pressing the Save button. They complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Problem: our application behaves currently quite silly and allows users to close a form window instead of pressing the Save button. This makes them complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?

Source Link

Tracking data change in GUI form

Problem: our users are being silly and close a form window instead of pressing the Save button. They complain they have to start afresh.

We are tasked with adding a confirmation dialog: "You have unsaved changes. SAVE / DISCARD / CANCEL". The dialog should not be displayed if none of the data was changed in the GUI, e.g. no text field's content was edited.

The form has scores of JTextFields, JCheckBoxes, JComboBoxes, etc. We could manually add listeners to all of them, setting some isChanged flag to true if any data was changed and then check that flag before optionally displaying the confirmation dialog. However, it's time-consuming and verbose. If some component is added in the future, it's easy to imagine its changes won't be tracked since one would forget to explicitly attach a listener to it.

What is the most optimal solution to this problem?