简体   繁体   English

Java MVC多个JFrame

[英]Java MVC multiple JFrame

I am creating an mvc java application with netbeans . 我正在使用netbeans创建一个mvc java应用程序。 first, when running the program, it should be only show 2 buttons "Teacher" & "Student". 首先,在运行程序时,应该只显示2个按钮“ Teacher”和“ Student”。

when I click the teacher button , it will leads me to viewTeacher where i can input or edit data about "Teacher" . 当我click the teacher button ,它将带我到viewTeacher ,在那里我可以输入或编辑有关"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? 我已经完成了整个MVC,但是我对第一个按钮感到confused :-我应该制作更多1个视图吗?

 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?

Instead of using multiple Jframes consider using multiple jPanels. 与其使用多个Jframe,不如考虑使用多个jPanel。

Say you have a MainPanel in a JFrame. 假设您在JFrame中有一个MainPanel。 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. 将所有内容写在一个类中会使代码变得复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM