5 Tips for Arabic Java Desktop Developers

I created this basic Java desktop infrastructure with Arabic display texts in about 15 minutes, though the RTL parts took a bit longer to get exactly right in the end, but were solved thanks to two sources discussed further down in this blog entry:

Notice that the application has a window system with undockable components, as well as a menu bar and a toolbar; all of which are pluggable because this is an example of a NetBeans Platform application, which is natively modular. Now "all" you need to do is code your business logic and you're done, since the infrastructure is ready and waiting for your domain-specific content. Consider the above as a generic template for Arabic Java desktop applications, i.e., the above application can run on Windows, Linux, Mac OSX, etc, i.e., on any operating system that supports Java SE.

Want to create the application you see above? Below are 5 tips to help you get started.

  1. Download the Arabic version of NetBeans IDE. Go to netbeans.org and choose Arabic in the IDE Language drop-down:

    Click Next, choose your distribution, and then click Download. You will see Arabic in the page that appears as the download starts:

  2. Don't worry about incomplete translations. Once you've downloaded and installed NetBeans IDE, take a look at the "locale" folders, which are within, for example, the "platform/modules" folder (as well as the "ide/modules" folder, for example). There you'll see that not only do you have Arabic JARs (denoted by the "ar_SA" extension), but also those for several other languages:

    Two concerns could come to the front of your mind at this point, neither of which are genuinely problems. First of all, you'll be concerned about, at the end of your application development, needing to bundle only the Arabic JARs, and not all the other ones, with your application. This blog entry, with thanks to Johan Walter, a Swedish NetBeans Platform developer, should help you out on that score. Secondly, once you've started up NetBeans IDE in Arabic (using the next step below), you might be concerned when you notice that not everything has been translated into Arabic, for example:

    But, you shouldn't be concerned about this either. Remember that the point of this exercise is to create your own Arabic application on the NetBeans Platform. As you'll see later in this blog entry, you have full control over all the texts in the NetBeans Platform, so you can change any text, throughout the NetBeans Platform, to Arabic. Therefore, the fact that NetBeans IDE itself, or even the NetBeans Platform itself, is not fully translated to Arabic really isn't a blocker to creating applications in Arabic on top of the NetBeans Platform.

  3. Set the locale of the IDE and of the application. Once you've downloaded and installed NetBeans IDE, go to the netbeans.conf file and use the "-J-Duser.language" and the "-J-Duser.region" settings, as shown below, to set the IDE to use the Arabic JARs:

    However, as noted earlier, the fact that you're creating an application in Arabic doesn't mean that the IDE itself must be set up in Arabic. You could create an Arabic application in the English NetBeans IDE, which might be the simplest way to do it. Once you've started up the IDE and you've created your new NetBeans Platform application, which is as always done via the New Project wizard, set the following in the platform.properties file of the application, so that the Arabic JARs are used for the application that you're creating:

    run.args.extra=-J-Duser.language=ar -J-Duser.region=SA
  4. Use the tools in the IDE. OK. So, now we're where the rubber meets the road. Everything has been set up and now we're creating our modules and coding the application. You're going to run into several things, all of which the IDE handles very gracefully for you. Here are solutions to all the potential stumbling blocks of which I am aware:
    • Menus, toolbars, and tabs need to be right-aligned. As luck would have it, quite some research has been done in this area already. Start by reading and using Tonny Kohar's insights on RTL layout, which are great, and very important in this context. Then also take a look at this module in Git, together with the discussion in http://netbeans.org/bugzilla/show_bug.cgi?id=96333. All my knowledge of RTL, as shown in the screenshot at the start of this blog entry, comes from these two sources.
    • Predefined NetBeans Platform display texts need to be translated to Arabic. Not a problem. Let's imagine you want to translate the "Window" menu to "شباك", for example. Right-click the application and choose Branding. In the Branding dialog, go to Resource Bundles, type the text you want to change, and then you'll need to read through the filtered strings intelligently to identify the one you need to change:

      Then right-click on the string you need to translate and choose Add to Branding. Then type your Arabic characters, which will then be saved in the application's 'branding' folder, in a properties file, where the entry will override the one provided by the NetBeans Platform itself.

    • New display texts need to be translated to Arabic. For example, when you create new window and new menu items, their display texts need to be Arabic. Not a problem. The NetBeans Java Editor can handle Arabic texts easily, for example, this is how the display text in the tab of a window, the tooltip in a window, and the menu item for opening the window are set, in a Java annotation that is converted to Bundle.properies entries when the file is saved:

    • The display text in the title bar needs to be translated to Arabic. Not a problem. Just right-click and choose Rename to rename the application and then use Arabic characters in the rename dialog. (Or go to the Branding dialog and use the General panel, which provides an Application Title field, where you can type Arabic characters.) That's how I ended up with this, which is what's displayed in the title bar:

  5. Download the completed sample. Want the sources of the above, i.e., the end result of all the work above? Go here, check out the application via Subversion, and open the project in NetBeans IDE 7.2:

    http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/App

    However, note that the IDE from which you run this application MUST include the Arabic JARs, i.e., you need to not only have NetBeans IDE 7.2, but the Arabic version of NetBeans IDE 7.2, as described in the first tip above. Note that the RTL support (i.e., the right-aligned menubar, toolbar, and tabs) is not part of the above download. Instead, refer to the sources mentioned in the previous tip if you're interested in those pieces.

Hope this is helpful to Java desktop developers wanting to create their software systems for Arabic end users. Using all the tools, components, and coding patterns provided by the NetBeans Platform is surely a lot simpler than reinventing the wheel all by yourself.

Funny Moment of the Day. Frank Caliendo is pretty clever with his impersonations, check this out on YouTube.

Comments:

Thank you,this article is very helpful
The only thing missing is that every thing should be rtl(taps,menu,etc...)

Posted by Alrowaily on August 16, 2012 at 08:59 AM PDT #

The menu and toolbar is now both RTL, look again at the screenshots. Tabs not yet, working on it.

Posted by Geertjan on August 16, 2012 at 09:19 AM PDT #

The tabs are now also right-aligned, with thanks to the code found at the end of this issue:

http://netbeans.org/bugzilla/show_bug.cgi?id=96333

Posted by Geertjan on August 16, 2012 at 09:49 AM PDT #

Great Post

Posted by guest on August 16, 2012 at 10:18 AM PDT #

thanks. It's very helpful for me.

Posted by djamdev on August 17, 2012 at 05:14 PM PDT #

if java source files are Unicode, why we cant use arabic directly? great post btw

Posted by guest on August 18, 2012 at 02:39 PM PDT #

And yet the IDE editor still doesn't handle Arabic text properly. See http://netbeans.org/bugzilla/show_bug.cgi?id=65158 , first opened in 2005.

Posted by Emilian Bold on August 20, 2012 at 04:46 AM PDT #

A complete swing application that analyzes Arabic text frequency is built using Java SE 6. It's got RTL tabs, tables, panes and what have you. Java makes it really fun to develop.

http://www.intellaren.com/intellyze

Posted by Mohsen on August 20, 2012 at 10:52 AM PDT #

Thank you! It is great.

Posted by Ehsan on September 14, 2012 at 09:19 AM PDT #

I have a question. Is there any way to use persian on NB-platform? Because Persian and Arabic has common letters and direction, although persian has 4 more letters.
And thank you again.

Posted by Ehsan on September 15, 2012 at 08:37 AM PDT #

Wow, Nice post Geertjan,
You've motivated me to learning Netbeans and Java, I wanna create some arabic program for educational use.

I appreciate you for your know well Arabic Language and for this great tutorial.

Thanks a lot

Posted by arhsa2 on January 28, 2013 at 06:24 AM PST #

arabic isn't display in my computer,..
I need to display arabic text from database in jtable,..
why I can do,.. ?

Posted by Java on April 30, 2013 at 10:34 PM PDT #

hi
i don't know how to make the all Main Window, toolbar and menu bar is right to left. can you explain how to embedded module git hub .
thanks

Posted by guest on February 06, 2014 at 04:51 AM PST #

hi
i read the blog but the issue of right to left orientation of netbeans platform is special for toolbar, dialog and menu bar but not all the main window in netbeans platform.
can you explain how you make your project is right to left for all components of netbeans platform (main window) like you make in first image of blog.
thanks

Posted by guest on February 09, 2014 at 06:14 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
24
25
26
27
28
29
30
   
       
Today