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


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea" Watch "JTextArea" New topic
Author

JTextArea

jamie ong
Greenhorn

Joined: Nov 05, 2001
Posts: 24
Hi,
anyone know whether is it possible to detect a new line within a passage when copy and paste into the textarea box and how to do so.
many thanks!
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi,
maybe I don't understand you right, but a newline in Java is "\n" and on some OS also "\r". So in your case I would create a StringTokenizer.

This would print you out:
this is a test
over two lines
In this way you could detect every line until newline.
Bye
Rene
jamie ong
Greenhorn

Joined: Nov 05, 2001
Posts: 24
hmm ok, so far i get what i want, how can i insert an extra word for every "\n" found?
thanks!
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Ok man, try this:

Please have a look to function replaceNewLine(). This function creates a new String by using every token. To every token you can add, what you want.
Hope this helps!
Rene
jamie ong
Greenhorn

Joined: Nov 05, 2001
Posts: 24
ok, thanks for your help! Rene
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea