Think of the classic installation process, where you have the βnextβ button, and when you click on it, the contents of the window change. To present this situation, I thought of two possible solutions:
-when "next" click, destroy the current JFrame and create a new JFrame, possibly pass useful information to its constructor (for example, the actual size of the window, the content inserted by the user in the current frame, ...)
- when you click "next", all components from the current JFrame are deleted and, if necessary, new components are added
The first solution looks better than OOprogramming, because I can store separate classes for different frames, and I can avoid the huge methods that empty the frame and populate it. However, the first solution sounds a little "dirty", and I have to pass a lot of parameters to a new frame. To present this situation, I would choose the second solution.
Now think of a menu with the option component: in this situation, I would create a new JFrame when I clicked on option so that I could fill it with options. This is the right decision? Is there a way that I can always know which one is the best solution? Are there any solutions that I haven't thought about?
source share