Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to populate JTextField value not in java bean

 
Vishal Karnik
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I'm working on a swing application which contains a login page and a bean to set and get the username and password. I'm unable to set the bean properties with the JTextField values




Please help.
 
Fred Kleinschmidt
Bartender
Posts: 417
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is it you are trying to set, what do you expect to happen, and what happens instead?
 
Rob Camick
Ranch Hand
Posts: 2675
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, don't use a null layout and don't use setBounds(...). Swing was designed to be used with layout managers.

Read the section from the Swing tutorial on Layout Managers for more information and working examples to get you started.

I would suggest a simple start would be to use the GridLayout.

Secondly you should be using JLabel/JTextField pairs to prompt for the input. Something like:

So your code might be something like:



Next you would need to create a JButton to do the login:


The tutorial also have examples of using a JButton and an ActionListener. So check out the table of contents and read the tutorial for more Swing basics.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic