0

I'm trying to make a simple program with Java, Swing, that shows you a Window and by clicking the button "Start" it should show you a new panel with a login interface (enter username, password, login).

I've read a question asked here that says that it's better to use only one JFrame and it makes sense because I don't want to start a new window between clicking "start" button and going to the login interface. But, how should I do this? I've created two JPanel containers named loginPanel and startPanel, but I don't know how to set visible loginPanel when the application runs, and then by clicking a button (in startPanel) set visible loginPanel (and obviously stop showing startPanel).

I'm using the graphical Swing interface that comes with NetBeans (because the IDE have greyed the zone to edit the code by yourself, IDK why).

Could anyone give me a example of what I'd like to do?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Jimmy L.
  • 21
  • 1
  • 5
  • Does [this](https://stackoverflow.com/a/65130430/1133011) answer your question? – David Kroukamp Jan 15 '21 at 05:21
  • 1
    I think that code ([mre] ) would have been clearer and shorter than the attempt to describe it. – c0der Jan 15 '21 at 06:26
  • A log-in, which really only requires two fields each with a label, is typically much smaller in width and height than a 'start' panel or the main GUI. So for this I'd use 1 main `JFrame` for the 'start panel, in a `CardLayout` ready to switch to the main GUI, and a `JDialog` to display the login panel. – Andrew Thompson Jan 15 '21 at 07:49
  • 2
    You asked: _Could anyone give me a example of what I'd like to do?_ I don't think that's how _stackoverflow_ works. I think that the idea behind _stackoverflow_ is to help people fix their code that doesn't work correctly for them. Search the Internet for ___java swing login page___ and you will find **many** examples of what you would _like to do_. Try to adapt those examples to your purposes and come back here when you hit a problem that you cannot find a resolution for. – Abra Jan 15 '21 at 08:55

0 Answers0