java - When I scroll the mouse Graphics removed of Textfield and dropdown from Table which I have set.Please help someone.Thanks in advanced -


without scroll bar fine if there more rows , use scroll bar in table view , scroll down or graphics of textfield automatically removed.

 public class comboboxrefresh extends application {      tablecolumn answertypecol;       tablecolumn answercol;      observablelist<string> answerselectlist;      combobox combobox;      textfield textfield;      public static void main(string[] args) {         launch(args);     }      @override     public void start(final stage primarystage) {          primarystage.settitle("table cell multiple components");           tableview<answeroption> table = new tableview<answeroption>();           table.seteditable(true);            final observablelist<answeroption> data =                      fxcollections.observablearraylist(                         new answeroption("a", "multiple choice"),                         new answeroption("1", "free text"),                         new answeroption("78", "free text"),                         new answeroption("d", "multiple choice"),                         new answeroption("a", "multiple choice"),                         new answeroption("2", "free text"),                         new answeroption("24", "free text"),                         new answeroption("d", "multiple choice"),                         new answeroption("a", "multiple choice"),                         new answeroption("7", "free text"),                         new answeroption("123", "free text"),                         new answeroption("d", "multiple choice"),                         new answeroption("a", "multiple choice"),                         new answeroption("3", "free text"),                         new answeroption("123", "free text"),                         new answeroption("d", "multiple choice"),                         new answeroption("a", "multiple choice"),                         new answeroption("5", "free text"),                         new answeroption("123", "free text"),                         new answeroption("d", "multiple choice")                     );          gridpane gridpane = new gridpane();          gridpane.setpadding(new insets(5));          gridpane.sethgap(5);          gridpane.setvgap(5);          answerselectlist = fxcollections.observablearraylist("a", "b", "c", "d", "invalid_answer", "no_answer");          answercol = new tablecolumn();         answercol.settext("answers");         answercol.setminwidth(210);         answercol.seteditable(true);         answercol.setcellvaluefactory(new propertyvaluefactory("answers"));          answercol.setcellfactory( new callback<tablecolumn<string, string>, tablecell<string, string>>() {             @override             public tablecell<string, string> call(tablecolumn<string, string> arg0) {                 return new anymethod();             }         });          answertypecol = new tablecolumn();          answertypecol.settext("answers type");         answertypecol.setminwidth(210);         answertypecol.seteditable(true);         answertypecol.setcellvaluefactory(new propertyvaluefactory("answerstype"));          table.setitems(data);         table.getcolumns().addall(answercol, answertypecol);          stackpane root = new stackpane();         scene scene =new scene(root, 500, 550);         gridpane.add(table, 1, 5,1,20 );         root.getchildren().addall(gridpane);         primarystage.setscene(scene);         primarystage.show();    }       private class anymethod extends tablecell <string, string>{          public anymethod(){              combobox = new combobox();             textfield = new textfield();             combobox.setitems(answerselectlist);         }          @override         protected void updateitem(string item, boolean empty) {             super.updateitem(item, empty);                  if (empty) {                 settext(null);                setgraphic(null);                 system.out.println("in empty");              } else {                 if( gettableview().getcolumns().get(1).getcelldata(getindex()).tostring().startswith("m")){                   system.out.println("making combobox");                  setgraphic(combobox);                 }                 else{                     setgraphic(textfield);                 }              }          }      }       public static class answeroption {         private final simplestringproperty answers;         private final simplestringproperty answerstype;           private answeroption(string answers, string answerstype) {             this.answers = new simplestringproperty(answers);             this.answerstype = new simplestringproperty(answerstype);         }          public string getanswers() {             return answers.get();         }         public void setanswers(string answers) {             this.answers.set(answers);         }          public string getanswerstype() {             return answerstype.get();         }         public void setanswerstype(string answerstype) {             this.answerstype.set(answerstype);         }     } } 

you should make combobox , textfield members of anymethod class, because after scrolling updateitem() sets existing combobox each cell cause visual mangling.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -