我想知道使用控制器將本地學生(模型)拉到我的視圖類中是否會使 MVC 設計模式無效。供參考我從來沒有將我的學生模型導入到視圖類中??刂破鱬ublic void saveStudent(int selectedRow, Student studentChanged){ studentList.getStudentList().set(selectedRow, studentChanged);}看法Student currentStudent;. . . .public StudentDetailedUI(StudentCntrl studentCntrIn, int selectedRowIn) { studentCntrl = studentCntrIn; selectedRow = selectedRowIn; if (selectedRow >= 0) { currentStudent = studentCntrl.getStudent(selectedRow); initComponents(); parseCurrentStudent(); } else { initComponents(); parseNewStudent(); }}. . . .JButton saveButton = new JButton("Save"); saveButton.addActionListener((ActionEvent e) -> { if (selectedRow != -1){ currentStudent.setFirstName(firstNameDisplayValue.getText()); currentStudent.setLastName(lastNameDisplayValue.getText()); currentStudent.setUniversity(universityDisplayValue.getText()); currentStudent.setGpa(Double.parseDouble(gpaDisplayValue.getText())); StudentDetailedUI.this.studentCntrl.saveStudent(selectedRow, currentStudent); StudentDetailedUI.this.studentCntrl.getStudentListUI(); } else { StudentDetailedUI.this.studentCntrl.addStudent(firstNameDisplayValue.getText() +", " +lastNameDisplayValue.getText() +", " +universityDisplayValue.getText() +", " +gpaDisplayValue.getText()); StudentDetailedUI.this.studentCntrl.getStudentListUI(); } });我的預期功能是使用列表詳細信息 GUI 更新列表中的現有學生。
添加回答
舉報
0/150
提交
取消