GUI Components Swing GUI for RTL Presentation?

How can I make Java Swing GUI components [right to left] for Arabic from a NetBeans Desktop application?

+6
java swing right-to-left
source share
4 answers

No need to just use:

Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT ) 

I believe swing components already have RTL support, right?

I do not know how and where you will do it in relation to non-poor people.

+8
source share

Call

  Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT ) 

gotta do the trick. But remember to use 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 that I forgot to mention.

+5
source share

You can use alignment, but this will not handle complexity if you have English letters or numbers embedded in your text.

It may be preferable to use some kind of stylized text widget, or even an integrated HTML / rich text viewer.

I don’t think standard JLabels can handle the difficulties otherwise.

+1
source share

you can use it if you have components inside panels inside contentPane

  Component[] component = contentPane.getComponents(); for(int i=0; i<component.length; i++){ component[i].applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); Component[] cp = ((Container) component[i]).getComponents(); for(int j=0; j<cp.length; j++){ try{ ((Component) ((JComboBox) cp[j]).getRenderer()).applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }catch(Exception e){ continue; } } } 
0
source share

All Articles