简体   繁体   中英

Make Radio Buttons Right To Left in the Java Swing

I have a form like this :

主界面

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM