java - Drawing a sub-table in a separate window from object within object -


let's have list<string> lstcat contains entire list of categories need in both tables.

i have observablelist<objecta> lstobject defined this:

public class objecta {     string mpid;     string date;     objectb insideobject;     } 

with object b defined as:

public class objectb {     string symbol;     int age;     } 

so lstobject = [objecta1, objecta2, ...]

what goal is have table appear of object a's members, , when click on row in table, table appears corresponding object b's members.

i have code first table:

private tableview init(stage primarystage) throws exception {     group root = new group();     primarystage.setscene(new scene(root));     tableview<objecta> tableview = new tableview<>;     list<string> lstcat = ...     observablelist<objecta> lstobject = ...      (int =0; lstcat.get(i).equals("symbol") == false;i++) {         tablecolumn<objecta,string> col = new tablecolumn<>(lstcat.get(i));         col.setcellvaluefactory(new propertyvaluefactory<>(lstcat.get(i)));         tableview.getcolumns().add(col);         }     tableview.setitems(lstobject);     return tableview; }   public void start(stage primarystage) throws exception {     tableview firsttable = init(primarystage);     // here's code need with. right have print statement,      // need generate new table corresponding objectb.     firsttable.setonmouseclicked(new eventhandler<mouseevent>()     {         @override         public void handle(mouseevent t) {             system.out.println("print when click")             }             });     scene scene = new scene(test);     primarystage.setscene(scene);     primarystage.show();     } 

the first table appears nicely, no problems @ all.

my work far:

i know make columns of new table be: go inside handle method.

tableview<objectb> innertable = .... (int = //element in lstcat objectb members start; i<lstcat.size();i++) {     tablecolumn<objecta,string> col = new tablecolumn<>(lstcat.get(i));         col.setcellvaluefactory(new propertyvaluefactory<>(lstcat.get(i)));         innertable.getcolumns().add(col);         } 

however, doesn't work because lstobject of type objecta innertable of type objectb. getting errors.

what missing here?

(and reason doing dynamically because tables working have more columns this, statically not option.

thank you!

edit:

i believe may have figured out.

i can interate on lstobject , make lstobjectb , add each objectb each objecta observablelist make innertable way.

unless there better way?

also how use mouseevent have new window appear new innertable?

it sub-row or something. not new window, else pops displaying new information.

after little bit of thought did figure out on own.

it may not cleanest/most efficient way, quick , dirty , allows keep moving forward.

i made return function class a's objectb.

public class objecta {     ...     public objectb getobjectb() {         return obejctb;     } 

and then, said, iterated on lstobject pull out objectb.

so ended looked this:

private static observablelist<objecta> getlstobject() {     return new lstobject.... } 

then made function:

private static observablelist<objectb> getlistobjectb() {         observablelist<objecta> lstobjecta =  getlstobject;         observablelist<objectb> lstobjectb = new fxcollection.observablearraylist();         (int =0;i<lstobjecta.size();i++) {             lstobjectb.add(lstobjecta.getobjectb());         }         return lstobjectb     } 

now had 2 observable lists, making tableview each had done before, , good.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -