javafx - How to access the new FxmlLoader without creating -


i create x class , class have tableview , load datas @ initialize method. click button add new object , open new scene, when try save object , show object in x class tableview use controller:

fxmlloader fxmlloader = new  fxmlloader(getclass().getresource("/fxml/timetablelist.fxml"));     fxmlloader.load(); 

but created new fxmlloader objects have been added twice. because initialize called again. how can solve problem. added method clear tableview i'm not sure true.

public class timetablelistcontroller {      private static observablelist<timetable> data = fxcollections.observablearraylist();;      private timetable atimetable;      public void initialize() throws sqlexception {         try {             timetablelisttableview.getitems().clear();             addtimetable();         }catch (sqlexception e){             e.printstacktrace();         }     }      private void addtimetable() throws sqlexception{         try {             list<timetable> timetablelist = main.dbmanager.gettimetables();              if(timetablelist.size() != 0){                 (int i=0; i< timetablelist.size(); i++){                     timetable atimetable = timetablelist.get(i);                     data.add(atimetable);                 }             }              timetablecolumn.setminwidth(200);             timetablecolumn.setcellvaluefactory(new propertyvaluefactory<timetable, string>("atimetable"){                 @override                 public observablevalue<string> call(tablecolumn.celldatafeatures<timetable, string> param) {                     return new readonlyobjectwrapper(param.getvalue().gettimetablename());                 }             });              timetableexplanationcolumn.setminwidth(200);             timetableexplanationcolumn.setcellvaluefactory(new propertyvaluefactory<timetable, string>("atimetableexplanation"){                 @override                 public observablevalue<string> call(tablecolumn.celldatafeatures<timetable, string> param) {                     return new readonlyobjectwrapper(param.getvalue().gettimetableexplanation());                 }             });              voyagenumbercolumn.setminwidth(200);             voyagenumbercolumn.setcellvaluefactory(new propertyvaluefactory<timetable, string>("avoyagenumber"){                 @override                 public observablevalue<string> call(tablecolumn.celldatafeatures<timetable, string> param) {                     return new readonlyobjectwrapper<string>(param.getvalue().getvoyagenumber());                 }             });          }catch (sqlexception e){             e.printstacktrace();         }          timetablelisttableview.setitems(data);     }      public void clickaddtimetable() throws exception{          fxmlloader fxmlloader = new fxmlloader(getclass().getresource("/fxml/timetablecreate.fxml"));         parent root =  fxmlloader.load();         stage stage = new stage();         stage.setscene(new scene(root));         stage.show();     } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -