java - Validating the new value of an editable table cell -


i have column inside of tableview allows "male" or "female" values.

the cell within column modifiable , when user inputs incorrect string such "test" creates alert notify them of error.

the problem having after alertbox closed, creates another alertbox same previous 1 , process loops forever.

the code have is:

    gendercolumn.setcellfactory((treetablecolumn<person, string> param) -> new genericeditabletreetablecell<person, string>(new textfieldeditorbuilder()));     gendercolumn.setoneditcommit((celleditevent<person, string> t)->{          if(t.getnewvalue().tolowercase().equals("male")){             ((person) t.gettreetableview().gettreeitem(t.gettreetableposition().getrow()).getvalue()).getgenderproperty().set("male");;          } else if (t.getnewvalue().tolowercase().equals("female")){             ((person) t.gettreetableview().gettreeitem(t.gettreetableposition().getrow()).getvalue()).getgenderproperty().set("female");;            } else {             alert alert = new alert(alerttype.error);             alert.settitle("invalid gender");             alert.setcontenttext("please specify gender either male or female");             alert.showandwait();             ((person) t.gettreetableview().gettreeitem(t.gettreetableposition().getrow()).getvalue()).getgenderproperty().set(t.getoldvalue());;              }      }); 

could me understand / fix why alert box generated?

thank you.


Comments