java - JavaFX Tableview with lists in populated object -


i know how populate tableview in javafx normal data types or custom class inclung normal data types. strugling how make tableview when class contains lists. using scene builder view, view files in fxml.

here class lists being duepersons , owepersons:

    public class overviewtable {      private simplestringproperty user = new simplestringproperty();     private simpledoubleproperty income = new simpledoubleproperty();     private simpledoubleproperty expenses = new simpledoubleproperty();     private simpledoubleproperty generaltotal = new simpledoubleproperty();     private observablelist<contributor> duepersons = fxcollections.observablearraylist();     private observablelist<contributor> owepersons = fxcollections.observablearraylist();      public overviewtable(string user){         this.user.set(user);     }      public overviewtable(string user, double income, double expenses) {         this.user.set(user);         this.income.set(income);         this.expenses.set(expenses);         this.generaltotal.set(income-expenses);;     }      public simplestringproperty userproperty() {         return user;     }      public void setuser(string user) {         this.user.set(user);     }      public simpledoubleproperty incomeproperty() {         return income;     }      public void setincome(double income) {         this.income.set(income);     }      public simpledoubleproperty expensesproperty() {         return expenses;     }      public void setexpenses(double expenses) {         this.expenses.set(expenses);     }      public void setgeneraltotal(){         this.generaltotal.set(this.income.doublevalue() - this.expenses.doublevalue());     }      public simpledoubleproperty generaltotalproperty() {         return generaltotal;     }       public list<contributor> duepersonsproperty() {         return duepersons;     }      public void setduepersons(observablelist<contributor> duepersons) {         this.duepersons = duepersons;     }      public list<contributor> getowepersons() {         return owepersons;     }      public void setowepersons(observablelist<contributor> owepersons) {         this.owepersons = owepersons;     }      public void addduepersons(contributor contributor){         this.duepersons.add(contributor);     }      public void addpersons(contributor contributor){         this.duepersons.add(contributor);     }  } 

here contributor class extends person class has "name" , "pid" attributes.

public class contributor extends person{  private simpledoubleproperty amount = new simpledoubleproperty();  public contributor(int pid, string name, double sum) {     super(pid, name);     this.amount.set(sum); }  public contributor(string name, double amount) {     super(name);     this.amount.set(amount);  }  public simpledoubleproperty getsum() {     return amount; }  public void setsum(double sum) {     this.amount.set(sum); }  public simplestringproperty nameproperty(){     return super.nameproperty(); } 

here java fxml view controller:

public class overviewcontroller{  @fxml private tableview<overviewtable> tableview;  @fxml private tablecolumn<overviewtable, string> usercolumn;  @fxml private tablecolumn<overviewtable, double> incomecolumn;  @fxml private tablecolumn<overviewtable, double> expensescolumn;  @fxml private tablecolumn<overviewtable, double> totalgeneralcolumn;  @fxml private tablecolumn<overviewtable, list<contributor>> personduecolumn;  @fxml private tablecolumn<?, ?> amountduecolumn;  @fxml private tablecolumn<?, ?> totalduecolumn;  @fxml private tablecolumn<?, ?> personowecolumn;  @fxml private tablecolumn<?, ?> amountowncolumn;  @fxml private tablecolumn<?, ?> totalowecolumn;  public void initialize() {      usercolumn.setcellvaluefactory(new propertyvaluefactory<>("user"));     incomecolumn.setcellvaluefactory(new propertyvaluefactory<>("income"));     expensescolumn.setcellvaluefactory(new propertyvaluefactory<>("expenses"));     totalgeneralcolumn.setcellvaluefactory(new propertyvaluefactory<>("generaltotal"));     personduecolumn.setcellvaluefactory(new propertyvaluefactory<>("duepersons"));      tableview.setitems(overviewtabqueries.getusers());   } 

as can see, of last columns not used yet, because want make work first 1 of lists in overviewtable class, , other. in above controller works fine first 4 columns, use normal string/double properties, when try input hte list, not work. note getting data mysql database on localhost, working correctly isn't problem.

so can me how solve problem? have searched around web couldn't find example tableview object used in tableview has 1 or more list attributes in it.

if wondering, here how result should when data loaded(please forgive paint skills): "due amount" , "owe amount" columns should integrate lists person/user's name , amount

any advices helpful :)


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -