Example usage for javax.swing JComboBox setComponentOrientation

List of usage examples for javax.swing JComboBox setComponentOrientation

Introduction

In this page you can find the example usage for javax.swing JComboBox 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:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper factory method for creating a language selector that provides functionality to change the locale.
 *
 * @param width/*from   ww  w . j  a  v  a 2  s  .c o  m*/
 *         the preferred width of the component in pixels
 * @return the newly created language selector
 */
protected JComboBox createLanguageSelector(int width) {
    Preconditions.checkArgument(width >= 0);
    final JComboBox<SupportedLocale> selector = new JComboBox(i18n.getSupportedLocales().toArray());
    selector.setSelectedItem(i18n.getCurrentSupportedLocale());
    selector.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            i18n.setLocale((SupportedLocale) selector.getSelectedItem());
        }
    });
    int height = selector.getPreferredSize().height;
    selector.setMinimumSize(new Dimension(width, height));
    selector.setMaximumSize(new Dimension(width, height));
    selector.setPreferredSize(new Dimension(width, height));
    selector.setMaximumRowCount(i18n.getSupportedLocales().size());
    selector.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale()));
    return selector;
}