Original Post
I have a JTextArea and a JTextField. When I enter text in the textfield and click a button it shows in the textarea. How can I read that text that I entered, have that text used in the next line, and have it display. Example: 1. I created an application that asks for your name and prints it out for you. 2. You run the application. 3. It asks for your name. 4. You enter your name. 5. It prints out your name on the next line. This is how it appears: Enter your name: DKN Your name is DKN Here is the code: Now what I did with the textfield and area. 1. The text area says "Enter your name" 1. You enter your name in the textfield. 2. You click a button. 3. The button copies what you put in the textfield onto the textarea. 4. Your name appears next to "Enter your name: ". This is how it appears: Enter your name: DKN Question is how can I read that name and have it print out on the next line on the textarea like what I did with my application? What should I read about swing that can teach me this? My book doesn't cover beyond the basics of design of swing and not how to use your application in a swing.
System.out.print("Enter your name: ");//ask for name
name = in.readLine(); //get name
System.out.println( "\n" + "Your name is " + name ); //tell what your name is