0

I am quite new to Java, having the following question:

I want my Swing Applications users to put in various textfields in some frames. That should happen like this: When the application is started, a frame opens with some textfields and a submit button. The submit button sends the textfields data to the main method and closes the active frame. Then a new frame opens with some more textfields and a submit button and so on.

How can I implement this in Java? I understood that building multiple frames is not best practice, but what is the alternative?

Thanks for your help!

1 Answers1

2

How can I implement this in Java? I understood that building multiple frames is not best practice, but what is the alternative?

IMO the best alternative in your case is to have only a window (probably a JFrame), and using a CardLayout to switch between (probably) panels when an action happens. Also read The Use of Multiple JFrames: Good or Bad Practice?

Besides official tutorials that have examples, this answer provide a commented example how to use CardLayout

Community
  • 1
  • 1
nachokk
  • 14,363
  • 4
  • 24
  • 53