java - Update TreeView on custom TreeItem property change -


i have extended treecell , treeitem class. mytreeitem contains custom property use inside mytreecell render graphics/font etc. problem when set mytreecell.customproperty i'm not sure how make treeview/cell redraw.

for example:

public class mytreeitem extends treeitem {     object customproperty      public void setcustomproperty(object customproperty) {         this.customproperty = customproperty          // how fire change event on treeview?     } } 

any comments on solution or (lack of) design approach appreciated.

there @ least 2 approaches (not including hack of nulling value, suggested in comments)

one manually fire treemodificationevent when setting custom property, in setcustomproperty:

public class mytreeitem extends treeitem {     object customproperty      public void setcustomproperty(object customproperty) {         this.customproperty = customproperty         treemodificationevent<t> ev = new treemodificationevent<>(valuechangedevent(), this);         event.fireevent(this, ev);     } } 

another make custom property "real" property , let interested parties (f.i. custom treecell) listen changes of property. example of how implement (and re-wire) listener have @ how defaulttreecell handles graphicproperty of treeitem.

which choose depends on context: first makes sure listeners treemodificationevents notified, second allows implement general treecell taking property (factory) of treeitem visualize.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -