aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Creating a login screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating a login screen" Watch "Creating a login screen" New topic
Author

Creating a login screen

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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).



Visit my blog! http://jameshambrick.com
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

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.
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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. "


If does not show anything when it runs.

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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.
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

I think I want to use a JInternalFrame like this one. Only problem is the textarea is not showing on the mainFrame.

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
James Hambrick wrote:I think I want to use a JInternalFrame like this one. Only problem is the textarea is not showing on the mainFrame.

No, you want a modal JDialog.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating a login screen