What is an efficient method to have a window change into a different window? When the user presses the next button, I would want it to perform another method that would create this second window. What is the appropriate listener class for this scenario?
Share
An example scenario for your question:
You may have a
JFramewhich is the starting point of your application, i.e. having single instance, main method, general initialization of components etc. You say you want to change windows. Let these windows be differentJPanelobjects that each of them are assigned to operate on different tasks. You can add these panels to your main frame. And changing these panels upon certain conditions will make your application capable of navigating between these panels/windows as well. So how to make this happen? Take a look atCardLayoutand use it to navigate between your predefined panels on their container frame.Take a look at this post, I have demonstrated
CardLayoutusage viaActionListener.