• Post Reply Bookmark Topic Watch Topic
  • New Topic

Putting data into JTextField

 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to put data back into a series of JTextFields. I have read about and experimented with the getComponents method.
I have read the data from the textfields and put them into a Set:



...but I am having trouble trying to figure out how to load the data back into the TextFields.

The following is how I got the data. How can I put it back?



Thank you.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be a situation where you're better off telling us what you're trying to achieve from a user's standpoint rather than how you're trying to achieve it in code. Perhaps the whole work-flow needs to be revised (or not).

Much luck!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are saying you know how to get text from a text field but can't figure out how to set text back to the text field? (Wink. Wink.)
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I need to figure out how to put data back ( using setText() of course )
back into the fields. The problem I am having is how to do so in a loop.

I read them using the following, but can't figure out a way to name the
field withing the loop in an iterative fashon. Like: (psuedo code)

jTextField?.setText("whatever");


 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this?



But why don't you just keep references to the JTextFields in the first place? That's the normal thing to do and it's much simpler.
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like popping them into an array?
 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. An array, or a List, or something like that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!