• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combine multiple jtextfield values into one.

 
N Hakim
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Im making an address book program. I have 4 input, where the user will type in Name, Admin No, Phone No and Email. How do I combine all these input to show in one jtextfield?

 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. A JTextField is meant to only show one line. To show multiple lines, use a non-editable JTextArea or perhaps even a JLabel. For the JLabel you would need to wrap the contents in HTML so you can use line breaks. For instance:
(without the HTML pieces, everything will be shown on one line)

Perhaps even better is to use a JPanel with a GridLayout where you put in 4 JLabels with the 4 values.
 
N Hakim
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. It worked. Thank you. But I have another question. Since this is an address book program, for example after I type in Name : John, Admin No: 20, Phone No: 123, Email: abc and these information will be shown in the jtextarea, how do I put another information in the same jtextarea without clearing this existing John information?
 
Randall Twede
Ranch Hand
Posts: 4353
2
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you probably want to save your JTextArea's in an array or ArrayList or other collection.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic