views:

690

answers:

2

I have a JTextArea which displays HTML of an Arabic web page. So it's essentially a mix of English and Arabic. In the JTextArea, with columns set to 30, certain text just disappears instead of wrapping properly. The weird thing is that if I copy the invisible text and paste it into Notepad, then I can see it in Notepad. If I change the number of columns to 40, everything displays fine. Any ideas?

A: 

Is it the 30th character which is disappearing? It's possible due to the script that the JTextArea cannot render the Arabic characters properly. So it's counting the characters correctly, but doesn't realize that they take up more space. Support for such fonts is not great, so you may want to write a custom renderer for your JTextArea to deal with this (so you can manually take into account the proper amount of space required per character in Arabic and adjust the line wrap accordingly).

Elie
+1  A: 

See this screenshot of the problem: http://www.freeimagehosting.net/image.php?400298479c.jpg

Elie, thanks for the response. Not sure I explained the problem properly though. On the left in the screenshot is the JTextArea. On the right is the selection from the JTextArea pasted into Notepad. Does this make more sense now?

Do you still get this issue even without the Arabic in the text, or is it only when you add the Arabic in? Try pasting the text from notepad into your text area with and without the Arabic and let me know what happens.
Elie
Yes, good idea. It seems that Arabic is not the problem here. It is something to do with tabs. All the lines that disappear begin with 5 tabs. If I remove one tab so that they begin with 4 tabs, then they appear fine in the JTextArea
what's your spacing for the tabs? Is it set to 6?
Elie
it's set to the default 8, but changing it doesn't help. I've seen other people reporting this problem too (http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=cef7db7d19c99e955793575f886?bug_id=6194377)My workaround is just going to be replacing the tabs w/ spaces. Thanks for helping me Elie