This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Creating a login screen  RSS feed

 
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

 
Sheriff
Posts: 24374
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!