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?
Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45

1 Answers1

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.

pundit
  • 322
  • 1
  • 7
  • So i should just make another form: viewTeacher & viewStudent in JPanel and link to the first 2 buttons according to the name? – cixpo pocix Aug 27 '13 at 12:49
  • and with JFrame.pack() if required – mKorbel Aug 27 '13 at 13:28
  • 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. – pundit Aug 27 '13 at 13:34