uitableview - Multiselection of cells with muose and copy of TableView using JAVAFX -


i have tableview editable , multiple selection enabled. wish enter new data columns , rows. wish select using mouse , press ctrl-c copy clipboard.

i can use column.setcellfactory (textfieldtablecell.fortablecolumn ()); , code works entering data excel. not select using mouse.

i read reference how can select multiple cells in tableview javafx mouse?. if try implement need use

final callback<tablecolumn<mydataclass, string>, tablecell<mydataclass, string>> mycellfactory = new dragselectioncellfactory (); column.setcellfactory (mycellfactory);.

then unable enter data cellfactory different now..

how may enter data excel , select mouse , use ctrl-c copy? help.

you can refactor code in link provided references cell factory, , "decorates" cells dragging functionality:

public class dragselectioncellfactory<s,t> implements callback<tablecolumn<s,t>, tablecell<s,t>> {      private final callback<tablecolumn<s,t>, tablecell<s,t>> factory ;      public dragselectioncellfactory(callback<tablecolumn<s,t>, tablecell<s,t>> factory) {         this.factory = factory ;     }      public dragselectioncellfactory() {         this(col -> new tablecell<s,t>() {             @override             protected void updateitem(t item, boolean empty) {                 super.updateitem(item, empty);                 if (empty || item == null) {                     settext(null);                 } else {                     settext(item.tostring());                 }             }         });     }      @override       public tablecell<s,t> call(final tablecolumn<s,t> col) {                     tablecell<s,t> cell = factory.call(col);           cell.setondragdetected(event ->  {               cell.startfulldrag();               col.gettableview().getselectionmodel().select(cell.getindex(), col);           });           cell.setonmousedragentered(event -> {               col.gettableview().getselectionmodel().select(cell.getindex(), col);           });         return cell ;       }    }  

then can do

tablecolumn<person, string> column = ...  column.setcellfactory(     new dragselectioncellfactory<person, string>(textfieldtablecell.fortablecolumn())); 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -