boolean () { synchronized (myLock) { myShowHiddenFiles = !myShowHiddenFiles; if (myCurrentDirectory != null) { var selection = myList.getSelectedObject(); myModel.setItems(myShowHiddenFiles ? new ArrayList<>(myCurrentContent) : ContainerUtil.filter(myCurrentContent, item -> item.visible)); myList.setSelection(selection != null ? List.of(selection) : List.of()); } return myShowHiddenFiles; } }