Example usage for java.awt Component setComponentOrientation

List of usage examples for java.awt Component setComponentOrientation

Introduction

In this page you can find the example usage for java.awt Component setComponentOrientation.

Prototype

public void setComponentOrientation(ComponentOrientation o) 

Source Link

Document

Sets the language-sensitive orientation that is to be used to order the elements or text within this component.

Usage

From source file:Main.java

public static void changeComonentOrientation(Component[] components, ComponentOrientation orientation) {
    for (Component c : components) {
        c.setComponentOrientation(orientation);
        if (c instanceof java.awt.Container)
            changeComonentOrientation(((java.awt.Container) c).getComponents(), orientation);
    }// w ww .  ja  va2 s.  c o m
}

From source file:MainClass.java

private void applyOrientation(Component c, ComponentOrientation o) {
    c.setComponentOrientation(o);

    if (c instanceof JMenu) {
        JMenu menu = (JMenu) c;
        int ncomponents = menu.getMenuComponentCount();
        for (int i = 0; i < ncomponents; ++i) {
            applyOrientation(menu.getMenuComponent(i), o);
        }//from w w  w  .j av a 2s  .co m
    } else if (c instanceof Container) {
        Container container = (Container) c;
        int ncomponents = container.getComponentCount();
        for (int i = 0; i < ncomponents; ++i) {
            applyOrientation(container.getComponent(i), o);
        }
    }
}

From source file:Main.java

@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    return component;
}

From source file:Main.java

private void setListCellRendererOf(JComboBox comboBox) {
    comboBox.setRenderer(new ListCellRenderer() {
        @Override/*w  ww . j av a2s .  c  om*/
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            Component component = new DefaultListCellRenderer().getListCellRendererComponent(list, value, index,
                    isSelected, cellHasFocus);

            component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            return component;
        }
    });
}