private void setSubjectDepartment() {
        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) subjectTree.getLastSelectedPathComponent();
        if (selectedNode == null) {
            return;
        }
                
        int treeLevel = selectedNode.getLevel();
        if (treeLevel != 2) {
            return;
        }
      
        Subject subject = (Subject) selectedNode.getUserObject();
        if (subject == null) {
            return;
        }
        
        Department subjectDepartment = (Department) departmentCombo.getSelectedItem();
        if (subjectDepartment == null) {
            return;
        }
        
        subject.setDepartment(subjectDepartment);
    }