You could try using a [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]DocumentFilter[/url]. If the input string contains a newline character then you would need to check the Document to see how many lines of text it already contains.
thanks camickr for your qucik replay.one clarification, JTextPane atuomatical wraps the content, is it addes the newline character for every line.thanksdaya