This is code in which i want to set text to text area from text field whenever "send button" or "Enter" is pressed on keyboard...I got by using button but how it is done using "enter key"
A simple solution is to specify the JRootPane's default button. You can get the root pane from the JFrame using getRootPane() and set the default button using setDefaultButton(myButton).
I'm not sure what will happen when the text components have focus though as they may consume the enter key press.
To quote the API docs:
"The default button is the button which will be activated when a UI-defined activation event (typically the Enter key) occurs in the root pane regardless of whether or not the button has keyboard focus (unless there is another component within the root pane which consumes the activation event, such as a JTextPane)."
Your send button already does this when you click on it, so you register your send button as the root pane's default button and when you press 'Enter' on the keyboard the send button will be activated ie it will be as if you clicked it.
BTW I've just looked at your code and noticed you are creating a new JFrame() on line 13. This line is not required as your class already extends JFrame.
Also you should move the calls to setSize and setVisible() to the end of the method ie after you have added all the components or the components don't display without resizing the frame.
And why do you think that is? Look at what you are passing to the method and compare it to other method calls you make where you pass an object reference.
For me, if I type some text into the text field and press the enter key, the text is transferred to the text area. Is that not what you want to happen?
I hadn't spotted that somewhere between your first post and the latest one you have added an ActionListener to the text field. That is causing the problem, remove line 31.