tags:

views:

1275

answers:

5

How can i make my Java Swing GUI Components [Right To Left] for Arabic language from NetBeans Desktop Application?

A: 
OscarRyz
A: 

You could use alignment, but that would not handle the complexities if you have English letters or numbers embedded within your text.

It might be preferable to use some sort of styled text widget or even an embedded HTML/rich text viewer.

I don't think that standard JLabels can handle the complexities otherwise.

Uri
JLabel display unicode letters. I think they relay on the system fonts and if the system fonts can display the letter then everything it's ok. For instance in my comp I can write "Extraño"
OscarRyz
+1  A: 

Don't you just have to use:

Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT )

I believe that the swing components all already have support for RTL, don't they?

Not sure how/where you'd do that in regards to netbeans, though.

John Gardner
A: 

The call of

 Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT )

should do the trick. But be sure to use the SwingConstants LEADING and TRAILING instead of LEFT and RIGHT in your layouts. The same goes for GridBagConstraints.LINE_START or LINE_END instead of WEST or EAST, and probably some similar cases which I forgot to mention.

Markus
A: 

Works perfectly. Thanks

naoufel
Please make this a comment for the accepted answer and delete this "answer".
Geoffrey Zheng