Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle ENTER key event in JTextArea

 
sahitya
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to enter multiple lines in the text area by clicking enter key. I am not able to do that. When I press an enter key, the control is getting out it.

Please help me asap.

Thanks in advance.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49432
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Please confirm that you have got the correct displayed name.

Not sure about your problem, and might not be able to help myself, but I think you would have better chances of a useful reply if you post more details, including a little code showing what you have written (use the "code" button below and ctrl-C ctrl-V to copy it), and more of an explanation of exactly what you want your code to do.

And less of the "asap" thank you very much!
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the class of the text area? Is it JTextArea, JEditorPane, JTextPane?

If it's JTextField, then you will need to change. It doesn't accept any line breaks. Instead, enter will trigger an ActionEvent.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just saw a good one on this in either the cattle drive or the faq's for jr
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic