Example usage for java.awt ComponentOrientation RIGHT_TO_LEFT

List of usage examples for java.awt ComponentOrientation RIGHT_TO_LEFT

Introduction

In this page you can find the example usage for java.awt ComponentOrientation RIGHT_TO_LEFT.

Prototype

ComponentOrientation RIGHT_TO_LEFT

To view the source code for java.awt ComponentOrientation RIGHT_TO_LEFT.

Click Source Link

Document

Items run right to left and lines flow top to bottom Examples: Arabic, Hebrew.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Layout");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    int horizontalGap = 20;
    int verticalGap = 10;
    Container contentPane = frame.getContentPane();
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap);
    contentPane.setLayout(flowLayout);/*from  www.ja v  a  2 s. c o  m*/
    frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    for (int i = 1; i <= 5; i++) {
        contentPane.add(new JButton("Button  " + i));
    }
    frame.pack();
    frame.setVisible(true);
}

From source file:GridLayoutDemo.java

public static void addComponentsToPane(Container pane) {
    if (RIGHT_TO_LEFT) {
        pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    }//w w w  . j  a v a 2s  . c om

    pane.setLayout(new GridLayout(0, 2));

    pane.add(new JButton("Button 1"));
    pane.add(new JButton("Button 2"));
    pane.add(new JButton("Button 3"));
    pane.add(new JButton("Long-Named Button 4"));
    pane.add(new JButton("5"));
}

From source file:FlowLayoutComponentOrientationRIGHT_TO_LEFT.java

public FlowLayoutComponentOrientationRIGHT_TO_LEFT() {
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(new JButton("OK"));
    getContentPane().add(new JButton("Cancel"));

    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
}

From source file:Main.java

public Main() {
    JComboBox itemsComboBox = new JComboBox(new String[] { "A", "L", "M" });
    itemsComboBox.setEditable(true);//  w ww  . ja va2  s .  c o m
    itemsComboBox.setMaximumRowCount(3);
    this.getContentPane().add(itemsComboBox);
    itemsComboBox.setVisible(true);
    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
    this.validate();
    this.repaint();
}

From source file:JComboBoxDemo.java

public JComboBoxDemo() {
    JComboBox itemsComboBox = new JComboBox(new String[] { "A", "L", "M" });
    itemsComboBox.setEditable(true);/*from  w w  w  .  j  a  va  2 s  .  c  om*/
    itemsComboBox.setMaximumRowCount(3);
    this.getContentPane().add(itemsComboBox);
    itemsComboBox.setVisible(true);
    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
    this.validate();
    this.repaint();
}

From source file:Main.java

public Main() {
    super("Main");

    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(new JButton("OK"));
    contentPane.add(new JButton("Cancel"));

    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
}

From source file:MainClass.java

public MainClass() {
    super("MainClass");

    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(new JButton("OK"));
    contentPane.add(new JButton("Cancel"));

    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
}

From source file:Main.java

public Main() {
    tabbedPane.setPreferredSize(new Dimension(300, 200));
    getContentPane().add(tabbedPane);/*from  w w  w  .  j a v a 2  s. com*/
    JPanel panel = new JPanel();
    tabbedPane.add(panel, "null");
    JTextField one = new JTextField("one");
    tabbedPane.add(one, "one");
    JTextField two = new JTextField("two");
    tabbedPane.add(two, "<html> Tittle  1 </html>");
    tabbedPane.setEnabledAt(2, false);
    tabbedPane.setTitleAt(2, "<html><font color=" + (tabbedPane.isEnabledAt(2) ? "black" : "red") + ">"
            + tabbedPane.getTitleAt(2) + "</font></html>");
    tabbedPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
}

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//from w  ww . j a  v  a  2 s .  c o  m
        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;
        }
    });
}