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

Adding jTextFields when required?  RSS feed

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

Say I have two jTextFields next to each other (side by side). One allows the user to put in a name of a person. The other allows the user to put in a phone number for that person. Is it possible to add another two jTextFields below these fields if requested by the user, using an 'Add another person' button, for example?

Thanks

SB
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you could, but what you're doing sounds more like you want a JTable.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you need a JTable. What you would do is when the user fires the Add Another Number event (be it a button or whatever) simply create new components and add them to your container.

Actually a just re-read the OP question and realized he isn't adding more phone numbers for a person but adding a new person. Yes, it does sound like a JTable would make more sense here with updatable rows. Although you could technically do it the way I first described.
[ December 10, 2007: Message edited by: Gregg Bolinger ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!