aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to handle ENTER key event in JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to handle ENTER key event in JTextArea" Watch "How to handle ENTER key event in JTextArea" New topic
Author

How to handle ENTER key event in JTextArea

sahitya
Greenhorn

Joined: May 01, 2008
Posts: 14
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

Joined: Oct 13, 2005
Posts: 39416
    
  28
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

Joined: Oct 27, 2005
Posts: 19720
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
I just saw a good one on this in either the cattle drive or the faq's for jr
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle ENTER key event in JTextArea