Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retriving value from the JTextField(Challanging task....)  RSS feed

 
Ajit Kanada
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I m generating dynamically the txtfields while showing the panel.
This the code for it..

for(int i=0;i<heading.size();i++)>
{
JLabel title = new JLabel((String)heading.elementAt(i));
title.setBounds(9,9+i*30,100,20);
title.setForeground(new Color(255,255,255));
panel.add(title);
content = new JTextField((String)data.elementAt(i));
content.setBounds(150,9+i*30,200,20);
content.setBackground(new Color(188,224,255));
panel.add(content);
}
On the same panel i have a update button.I want to get the text in each txtfield in a vector on click of update button..In actionPerformered if i write content.getText() i get text in the last txtfield.Can some one tell me how can i get all the values in the txtfields on click of button

i think i m clear
Thanx in advance
Ajit
 
marc bowden
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajit
At the moment you overwrite the reference in your 'content'
variable each loop. Hold a *vector* of content variables, perhaps?
Marc
 
Ajit Kanada
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc
Thax for prompt reply..What u said is working perfectly..
Thanx alot
Bye
Ajit
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!