java - setRowFactory issue in JavaFX -


I have a problem with my app that uses Java FAX ... in a scene I have a tableview In which there is a list of people and I want to change the line style one person here is my code:

  personTable.setRowFactory (new callback & lt; TableView & lt; person & gt; TableRow & Lt; Person & gt; & gt; () {@Override Public TableRow & lt; Person & gt; Call (TableView & lt; Person & gt; personTableView) {New TableRouter Formats}}}}  < / Pre> 

...

  private classes TableRowRightFormat TableRow Expands {@Override protected void updateItem (Object O, Boolean B) {super.updateItem (o, b); if (o == zero) {return;} GetStyleClass (). Remove ("headerson"); Add (gettyplecass). ("Headpasaron");}}}   

and it is a person (id = 2) .getId () == 2) ), But when I scroll up my table and when the id = 2 person with the id disappears the other person! = 2 style that is called 'headpieces' (always on the visible elements in the tableview, the style of a person is 'predominant', but the above version is being executed once). What's the problem

Update: I have my code jawfx 2.2 and jdk 8 and this is my simple The case of the test seemed to work fine. The argument seems right; One thing you really need to be careful about in these style-based class-based cell and row implementations, is making sure that you do not add more than one copies of the string given in the list of a style category - in its implementation Looks OK Double check and make sure that you have the same string in the addition (...) and Remove (...) methods.

I want to completely bullet-proof these demonstrations at a small price:

  private end string headspace style class = "headprint"; Private Category TableRowRightFormat TableRow & lt; Person & gt; {@Override Secure Zero Update Item (Person P, Boolean B) {Super. Additional item (P, B); ObservableList & LT; String & gt; StyleClass = getStyleClass (); If (p! = Null & amp; amp; p.getId () == 2 & amp; amp; (! Style classes. Contains (headPersonStyleClass)) {styleClass.add (headPersonStyleClass);} and {// All Remove events: styleClass.removeAll (collectionsynthesion (headspace style class));}}}   

If you are using Java FX 8, then enter a PseudoClass is a better way to use.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -