public void onClick$deleteBtn(Event event) { Window canvasBoardWindow = (Window) zkpaintWindow.getFellow("canvasInc").getFellow("canvasBoardWindow"); Canvas cvs1 = (Canvas) canvasBoardWindow.getFellow("cvs1"); int size = shapeListBox.getItemCount(); System.out.println(size); for (int i = size - 1; i > -1; i--) { if (!shapeListBox.getItemAtIndex(i).isSelected()) continue; System.out.println(i); cvs1.remove(i); ((ListModelList) shapeListBox.getModel()).remove(i); } }