JavaFX 8 TableView: If the FixedCellSize property is being used, a column cannot be hidden -


when paint background of column , fixed size of cell, happens when hidden column: enter image description here

if comment line: "table.setfixedcellsize(24)" works correctly: enter image description here

but need fix size of cell... ¿does error have solutions?

many , sorry poor english.

you can run example:

import javafx.application.application; import javafx.beans.property.simplestringproperty; import javafx.collections.fxcollections; import javafx.collections.observablelist; import javafx.geometry.insets; import javafx.scene.group; import javafx.scene.scene; import javafx.scene.control.checkbox; import javafx.scene.control.tablecolumn; import javafx.scene.control.tableview; import javafx.scene.control.cell.propertyvaluefactory; import javafx.scene.layout.vbox; import javafx.stage.stage;  public class test extends application {      @override     public void start(final stage stage) {          // create items         final observablelist<person> data =          fxcollections.observablearraylist(new person("ruben", "martin"),         new person("ruben", "martin"), new person("ruben", "martin"));          // create columns         final tablecolumn<person, string> firstnamecol =          new tablecolumn<>("first name");         firstnamecol.setcellvaluefactory(         new propertyvaluefactory<>("firstname"));          final tablecolumn<person, string> lastnamecol =          new tablecolumn<>("last name");         lastnamecol.setcellvaluefactory(         new propertyvaluefactory<>("lastname"));          // create table         final tableview<person> table = new tableview<>();         table.setfixedcellsize(24);         table.setitems(data);         table.getcolumns().addall(firstnamecol, lastnamecol);          // create checkbox         final checkbox checklastname = new checkbox();         checklastname.settext("last name");         checklastname.setselected(true);         lastnamecol.setstyle("-fx-background-color:yellow");         lastnamecol.visibleproperty().         bindbidirectional(checklastname.selectedproperty());          final vbox vbox = new vbox();         vbox.setspacing(5);         vbox.setpadding(new insets(10, 0, 0, 10));         vbox.getchildren().addall(table, checklastname);          final scene scene = new scene(new group());         stage.setwidth(450);         stage.setheight(550);         ((group) scene.getroot()).getchildren().addall(vbox);         stage.setscene(scene);         stage.show();     }      public static void main(final string[] args) {         launch(args);     }      public static class person {          private final simplestringproperty firstname;         private final simplestringproperty lastname;          private person(final string fname, final string lname) {             this.firstname = new simplestringproperty(fname);             this.lastname = new simplestringproperty(lname);         }          public string getfirstname() {             return this.firstname.get();         }          public void setfirstname(final string fname) {             this.firstname.set(fname);         }          public string getlastname() {             return this.lastname.get();         }          public void setlastname(final string fname) {             this.lastname.set(fname);         }     } } 

probably workaround works:

stringbinding sb = bindings.when(lastnamecol.visibleproperty())                 .then("-fx-background-color:yellow")                 .otherwise("");         lastnamecol.styleproperty().bind(sb); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -