Behzad Hassani
Behzad Hassani

Reputation: 2139

Make Radio Buttons Right To Left in the Java Swing

I have a form like this :

Main GUI

as you see this is a persian form. I want to make radio buttons RIGHT TO LEFT means that i want the radio come first then the comment text of radio appears. I have used this function:

private void makeComponentsRightToLeft(){       
        Component[] components = this.getComponents();
        for(Component comp:components){
            if(comp instanceof JComponent){
                comp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);                
            }            
        }
    }

in the constructor of the form. but nothing change, what should I do for this problem?

Thank you for your helping. Ummmm some thing that I forgot is that I use group Layout for my design

Upvotes: 1

Views: 1268

Answers (1)

Jean-Baptiste Yunès
Jean-Baptiste Yunès

Reputation: 36441

To change orientation of the whole hierarchy use applyComponentOrientation. There is also an alignment property to radio buttons (setHorizontalAlignment): LEADING for text before button and TRAILING for the converse, but LEADING is the default and is compatible with LTR-RTL switches.

Upvotes: 2

Related Questions