java - Is there an elegant way to make JTable stop editing when user closes the application window? -
i trying find out elegant way make jtable stop cell editing (cancel actually) when user closes main application window. know can done using windowadapter work need reference window. problem not have it.
an abrupt exit may need handled @ several levels.
assuming user must navigate out of table click on exit control, should desired result setting table's
"terminateeditonfocuslost"
property.table.putclientproperty("terminateeditonfocuslost", true);
if have resort
windowlistener
or similar, can stop editing explicitly shown here.celleditor celleditor = table.getcelleditor(); if (celleditor != null) { if (celleditor.getcelleditorvalue() != null) { celleditor.stopcellediting(); } else { celleditor.cancelcellediting(); } }
because host owns frame decorations, platforms require special handling intercept close control, discussed here.
preferences
makes best effort persist updated values.
Comments
Post a Comment