Reputation: 9
Alright so im making a program in Java that asks the user for multiple details in continuous frames in GUI, My main question would be is there a way to put all frames in one class, and not have to create a class for each frame.
So here is what im doing:
1st frame:
Please give me your name: [User puts name here] //Then click ok
2 frame:
Please put the first numer: [user puts first number]
Please put second number: [user puts second number]
//then click next
and so on
I cant figure out a way to do this without creating a new class for each frame.
Is there a way to put all frames in the same class. Thanks in advance
Upvotes: 0
Views: 98
Reputation:
In this case, it sounds like you do not actually need multiple frames; rather you need one frame, and its content changes. You could use several JPanels for the individual pages, and switch between them.
That said, you should not mash the entire dialog into a single class; rather you should practice separation of concerns, cut code into reasonable chunks, and possibly use design patterns like MVC.
Upvotes: 2