Java MVC多个JFrame [英] Java MVC multiple JFrame

查看:66
本文介绍了Java MVC多个JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用netbeans创建一个mvc Java应用程序.首先,在运行程序时,应仅显示2个按钮"Teacher"和"学生".

I am creating an mvc java application with netbeans. first, when running the program, it should be only show 2 buttons "Teacher" & "Student".

当我click the teacher button时,它将带我到viewTeacher,在这里我可以输入或编辑有关"Teacher"的数据.学生按钮也是如此.

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.

我已经完成了整个MVC,但是对于第一个按钮我是confused: -我应该多观看1张吗?

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?

推荐答案

与其使用多个Jframe,不如考虑使用多个jPanel.

Instead of using multiple Jframes consider using multiple jPanels.

假设您在JFrame中有一个MainPanel.主面板将具有查看面板和控制面板.底部的控制面板和上方的查看面板.单击特定按钮时,将相应的面板(例如教师面板)添加到视图面板.您可以在开始时创建教师面板和学生面板,但仅在单击时显示它们.

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.

这篇关于Java MVC多个JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆