Skip to main content

Bidirectional Text Inconsistencies: Bug # 4701238

Posted by joconner on November 2, 2005 at 3:57 PM PST

I received an email from one of my good friends in the Java internationalization group at Sun. He's asking for feedback on how his group should fix a bidirectional text layout bug in Swing. His email explains it quite well, so I quote it below.

Please allow me to solicit your opinions on a bidi problem in Swing
that we have been facing for a long time.  The problem is regarding
the default text run direction in Swing components.  The gory detail
of the problem itself is described in the bug report 4701238, but
here is the summary of it:

1. In Swing text components, such as JTextField or JTextArea, the
default run direction of the text follows the component orientation.
So, for example, if those text components are laid out Left-To-Right,
the text in those components start from the left edge of the

2. Other Swing components that deal with text, such as JLabel, draw
text based on the first character in the text which has strong
direction property.  So if the first character of the text is one of
the alphabets, the text starts from the left edge of the component,
and if the first character is one of Arabic/Hebrew, it starts from
the right edge.

So if I draw a swing application with RTL text, it looks like this
(ARABIC is the Arabic text in logical order):

LTR component orientation:
| JTextArea:                      |
| +---------------+               |
| |CIBARA         |               |
| +---------------+               |
|                                 |
|                                 |
| JLabel:                         |
| +---------------+               |
| |         CIBARA|               |
| +---------------+               |

As you can see, the text direction is inconsistent.  We need to
resolve this inconsistency, but just don't know which one is more
acceptable for those who speak bidi languages natively.  Of course, I
would not be surprised if there is no definitive answer, because the
initial assumption (RTL text in LTR component orientation
environment) is somewhat inconsistent in the first place.

I would appreciate your feedback.

Got any ideas, help, suggestions? Let me know!

Related Topics >>