okay I am trying to create a chat program but having trouble with the GUI. The main screen needs to come up, but the login screen(possibly a dialog) come up and check for login details first. The user will not be able to access the main screen until the login is verified. I have code to show the main screen, below as well as the items I want added to the login screen(ie. usernameTxt, passwordTxt, loginButton).
Paul Clapham wrote:So basically you need a CardLayout, which displays the login panel when the program starts. After the user puts in the correct credentials you change it to display the main panel.
Here's the code I have from looking at examples online(since the API from the java site seems to confuse me most of the time), and this paragrah from Sun's CardLayout tutorial is not promising.
"Note: This lesson covers writing layout code by hand, which can be challenging. If you are not interested in learning all the details of layout management, you might prefer to use the GroupLayout layout manager combined with a builder tool to lay out your GUI. One such builder tool is the NetBeans IDE. Otherwise, if you want to code by hand and do not want to use GroupLayout, then GridBagLayout is recommended as the next most flexible and powerful layout manager. "
I got the login screen to show after adding it to the cards Panel before the main window. This is not what I want at all. The login screen is the size of the main screen. I want a general login screen. You konw where you can see the main window in the background and a smaller little login window pops up. You cannot access the main window until you log in. I guess with this I could possibly resize it when it's the login screen an then resize it again after the user logs in, but that would probably look weird.
I need a child window, maybe a Dialog box or something. Just not sure how to go about it.
Am I even supposed to be able to place something on the "main window"??? Or is it always suppoed to be a blank white window? All the example I have seen show a blank window.
If I change JDesktopPane to JPanel I can see the textarea on the "main window" but then the login screen's layout is all messed up. All the text boxes, labels and buttons are in a single line. And I can edit the textarea before the login window closes.