0

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

So i should just make another form: viewTeacher & viewStudent in JPanel and link to the first 2 buttons according to the name?
and with JFrame.pack() if required
This is just an idea you can implement what suits you. I would model it like this, viewTeacherPanel and viewStudentPanel will each separate classes extending JPanel and having there won lay out and controller. On action performed event i.e click on the buttons add the respective panel to your main panel. after adding the custom panel repaint your main frame to show the effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.