( ) , JTable changeSelection(), , , , - OO, save/discard. , ?; -)
jTableMemberList = new JTable() {
public void changeSelection(int rowIndex, int columnIndex, boolean toggle,
boolean extend) {
if (editModeIsActive && getSelectedRow() != rowIndex) {
Object[] options = {"Save", "Discard", "Cancel"};
int n = JOptionPane.showOptionDialog(this,
"There are unsaved changes for the "
+ "currently selected member.\n\n"
+ "Would you like to save them?",
"Save changes?",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[0]);
if (n == JOptionPane.YES_OPTION) {
saveChanges();
} else if (n == JOptionPane.NO_OPTION) {
discardChanges();
} else {
return;
}
}
super.changeSelection(rowIndex, columnIndex, toggle, extend);
}
};
, . gotcha, ...
, - !