javafx - Can't clear all items (elements) in an ObservableList -


i've couple of copied elements in observablelist use copy/paste operations in tableview. name of table cptable (copy , paste table) storing copied elements , paste elements stored in table. after each paste operation want clear contents of cptable before copy other selected items ctrl+c. error:

javafx application thread" java.lang.unsupportedoperationexception: not supported.
@ com.sun.javafx.scene.control.readonlyunbackedobservablelist.remove(readonlyunbackedobservablelist.java:246)

here pseudocode:

if (cptable !=null) {     //first, copied items removing elements      observablelist<string> copieditems = cptable.getitems();                                      int size = copieditems.size();      // remove elements      for(int i=0;i<size;i++) {         copieditems.remove(i);     }     cptable.setitems(copieditems); //clear cptable setting empty list } 

this method copies contents of selected items , puts in cptable

public tableview<string> copyselectiontoclipboard(tableview<string> table) {                 observablelist<string> data =     table.getselectionmodel().getselecteditems();                  tableview<string> tmp = new tableview<>();     tmp.setitems(data);     return tmp; 

}

when ctrl+c pressed following line puts copied items in cptable:

cptable = copyselectiontoclipboard( (tableview<string>) keyevent.getsource()); 

as mentioned want clear cptable contents after pasting items in table.

just clear observable list. looks should use copieditems.clear(); should clear table.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -