void (TreeSelectionEvent e) { TreePath selectionPath = myLeftTree.getSelectionPath(); if (selectionPath != null) { myPathField.setText(StringUtil.join(selectionPath.getPath(), o -> { Object userObject = ((DefaultMutableTreeNode)o).getUserObject(); return userObject instanceof MyUserObject ? ((MyUserObject)userObject).myModule.getName() : ""; }, " : ")); DefaultMutableTreeNode selection = (DefaultMutableTreeNode)selectionPath.getLastPathComponent(); if (selection != null) { updateRightTree(((MyUserObject)selection.getUserObject()).myModule); } } }