问题
I am creating an mvc java application with netbeans. first, when running the program, it should be only show 2 buttons "Teacher" & "Student".
when I click the teacher button, it will leads me to viewTeacher where i can input or edit data about "Teacher". same goes for student button.
I have finished the whole MVC but I am confused about the first buttons:
- should I make more 1 view?
viewForm, viewTeacher, viewStudent.
viewForm is the first 2 buttons appear: "Teacher" & "Student"
OR
- should i put all the codes inside viewForm and create viewTeacher & viewStudent form on other components?
回答1:
Instead of using multiple Jframes consider using multiple jPanels.
Say you have a MainPanel in a JFrame. The main panel will have a view panel and a control panel. The control panel at the bottom and view panel above it. When clicked on a particular button add the corresponding panel say, teacher panel to the view panel. You can create the teacher panel and student panel at the start but show them only when clicked.
Writing every thing in one class will make the code complex.
来源:https://stackoverflow.com/questions/18465358/java-mvc-multiple-jframe