Cancel Dialog Changes

Learn how to cancel any changes made in the dialog.

Cancelling changes by closing the dialog

Add the instance variable needed to keep track of whether the user canceled his changes.

  • Go back to OptionsDialog.java.
  • Add a private boolean instance variable called canceled, initialized to true.
  • Add a method called isCanceled(). It should take no parameters and return a boolean: canceled.
...
private int cols = 0;
private int type = 0; _____________ canceled = ________;
   ...
_____________ isCanceled(______) { 
   return ____________;
}
...

Get hands-on with 1200+ tech skills courses.