Search code examples
javaswingjtablearabicidn

How to force JTable to NOT invert text in the case it contains arabic characters?


I have the following text:

وزا.word

But when displaying it on my JTable it looks like this:

word.وزا

In every JLabel or TextArea or any other input it does look like the original text:

وزا.word

ONLY on the JTable I am having such problem.

I do not care if it is making sense or not, and yes I know the Arabic Language is written from right to left. My guess is Java is detecting it and automatically inverting it, but I do not want it to.

Note: I have no idea what وزا means, and for practical purposes I don't care. It's also irrelevant for this case wether وزا.word does not make sense and word.وزا does or viceversa.

Note 2: The text, reversed or not is always aligned to the left (as I expect it to).

Thanks in advance.


Solution

  • At a guess, your default Locale is giving the default renderer a ComponentOrientation that is inconsistent with your other settings. You might try creating a custom renderer having the preferred orientation using one of the approaches suggested here.

    Addendum: java.text.Bidi supports bidirectional reordering; you may be able to use unicode format control code points, as suggested in this Q&A.