We've done it! We solved the problem of making the JTextComponent objects of Java's Swing API treat RTL (right-to-left) languages such as Arabic or Urdu with all due respect. This means that now, and for the first time since the advent of the Java programming language over a decade ago, your mouse cursor will appear where you place it, and not at the opposite, complementary position of the edit line.
This phenomenon has blocked software developers from designing bidirectional professional text editors in one of the most powerful and widespread programming languages of our times: Java.
If you are interested in learning all about the problem, then you must be a software developer or someone who likes them. Read on.
- During the design of a desktop version of Intellark back in 2006, Intellaren's new Arabic keyboard layout, I ran through this problem when trying to edit my written lines of text: Place the mouse cursor in a certain position to start editing on a JTextComponent object that specializes in displaying text (e.g., jTextField, jTextArea, jTextPane...), the mouse cursor appears on the opposite end of the edit line! As a result, newly added text appears at the wrong location in the edit line.
In search for a solution... been there, done that
- First, I inspected the Java developer forums to study the phenomenon... it turns out it is a nasty old bug that is inherent in Java SE, which explains why there isn't a single editor written in Java that caters for RTL languages.
- On Oct 30, 2008, I reported the problem on Sun forums in detail. See http://forums.sun.com/thread.jspa?threadID=5344007.
- On Nov 24, 2008, I investigated what it would take to get Sun Microsystems (now taken-over by Oracle Inc) to notice the issue. See http://forums.sun.com/thread.jspa?threadID=5350203.
- Needless to say in relation to the above point, the fee is paid and after several emails exchanged between Sun and myself, all I managed to do is to get the phenomenon officially recognized as a bug. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6787890 and the numerous comments therein. To see the bug in action, don't miss the video provided by "UrduLink" at the bottom of the link where the problem is visually highlighted, together with sad music for sound effects.
- Not surprisingly, our bug, one of the newest among hundreds of registered bugs, found its way to the third position among all bugs in terms of votes! This is an indication to the anxiousness and suffering of international Java developers to combat the phenomenon and build word processors in Java -- the favorite programming language of many. See our bug at the top of the list here: http://bugs.sun.com/bugdatabase/top25_bugs.do.
- Later communication with Sun revealed that the only way for Sun to look into the problem is to open a contract, which comes with a ≥ $$$$ price tag.
- I put an ad on Intellaren's website soliciting professional Java developers to see if the bug could be solved for some fee, but to no avail.
- Over the years, I received many supporting emails and offers to join forces to study, analyze, and work jointly on a fix. But... how could I, and cloning is still far from being applied on humans?
Living with the bug
While working on Intellyze, Intellaren's letter and word frequency analyzer and editor at the same time, everything seemed perfect with our pride and joy versatile, multi-function desktop application. But, there was always that bug to deny us a full content with our unparalleled product. And... many months passed...
Rami, the QD (or, the quick-and-dirty if you like) takes a look
Well, it is the simple good old three-step process really. Here it is.
- February 24, 2010: Rami, a software engineer at Intellaren inquired about the problem for the first time
- I, another software engineer at Intellaren, explained it... but it seems I never told the guy he couldn't fly. A couple of days later...
- Rami sent me over googleTalk a mini executable jar file named: fix.jar, which he claimed it contained the fix, with a playful facial smile!
Okay, I inspected the Java code and... other than the fact that it was poorly indented... it did feature a sharp, clean and complete solution to the over-a-decade-old problem!
That's why all impacted software developers around the world owe it to Rami to... hate him =)
Where to go from here
- Intellyze 3.0 is currently going through the final stages of testing and fine-tuning and will be out and about pretty soon. Frankly, we want Intellyze to enjoy exclusive rights to featuring our solution for a little bit of time before we decide how to proceed.