java - javafx unable to edit tableview row data -


i want edit tableview row data had codes edit cell data not working in project fxml code:

<tableview fx:id="table" layoutx="112.0" layouty="25.0" prefheight="430.0" prefwidth="505.0">                            <columns>                               <tablecolumn fx:id="tablecol" prefwidth="490.0" text="schedule item">                                   <cellvaluefactory>                       <propertyvaluefactory property="firstname" />                   </cellvaluefactory></tablecolumn>                            </columns>                         </tableview> 

in fxml fx:id="tablecol" , fx:id="table" used

code:

@fxml     private tableview<person1> table;  @fxml     private tablecolumn<person1, string> tablecol;     /**      * initializes controller class.      */     @override     public void initialize(url url, resourcebundle rb) {   tablecol.setcellfactory(textfieldtablecell.fortablecolumn()); tablecol.setoneditcommit(     new eventhandler<celleditevent<person1, string>>() {         @override         public void handle(celleditevent<person1, string> t) {             ((person1) t.gettableview().getitems().get(                 t.gettableposition().getrow())                 ).setfirstname(t.getnewvalue());         }     } );         try{        class.forname("com.mysql.jdbc.driver");             connection con=(connection)drivermanager.getconnection("jdbc:mysql://localhost:3306/schoolmanagement","root","root");             string sql="select * `scheduleitem` ";            statement stm=(statement) con.createstatement(); resultset rs=stm.executequery(sql); while(rs.next()){     table.getitems().add(new person1(rs.getstring(2))); }          }          catch (classnotfoundexception | sqlexception e) {          }     }      }       public class person1 {     private final stringproperty firstname = new simplestringproperty("");      public person1(string firstname) {         setfirstname(firstname);      }      public string getfirstname() {         return firstname.get();     }      public void setfirstname(string name) {         this.firstname.set(name);     }      public stringproperty firstnameproperty() {         return firstname;     } 

please why unable edit cell data.

thank you.

while tablecolumns editable default, tableviews not. need

<tableview fx:id="table" editable="true" ...> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -