Example usage for java.awt ComponentOrientation isLeftToRight

List of usage examples for java.awt ComponentOrientation isLeftToRight

Introduction

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

Prototype

public boolean isLeftToRight() 

Source Link

Document

HorizontalLines: Do items run left-to-right?
Vertical Lines: Do lines run left-to-right?
This will return true for horizontal, left-to-right writing systems such as Roman.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Locale myLocale = Locale.getDefault();
    ComponentOrientation ce = ComponentOrientation.getOrientation(myLocale);
    System.out.println("Is horizontal? " + ce.isHorizontal());
    System.out.println("Is left to right? " + ce.isLeftToRight());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Locale myLocale;/*from w ww  .  j  av  a 2 s  .co m*/
    if (argv.length < 2)
        myLocale = Locale.getDefault();
    else
        myLocale = new Locale(argv[0], argv[1]);
    ComponentOrientation ce = ComponentOrientation.getOrientation(myLocale);
    System.out.println("Is horizontal? " + ce.isHorizontal());
    System.out.println("Is left to right? " + ce.isLeftToRight());
}

From source file:Main.java

/**
 * Copies component orientation from one component to another.
 *
 * @param from/*  ww w  .j a  va  2 s.  co m*/
 *            component to copy orientation from
 * @param to
 *            component to copy orientation into
 */
public static void copyOrientation(final Component from, final Component to) {
    final ComponentOrientation fo = from.getComponentOrientation();
    if (fo.isLeftToRight() != to.getComponentOrientation().isLeftToRight()) {
        to.applyComponentOrientation(fo);
    }
}

From source file:com.projity.contrib.calendar.JXXMonthView.java

/**
 * Sets the language-sensitive orientation that is to be used to order the
 * elements or text within this component. Language-sensitive LayoutManager
 * and Component subclasses will use this property to determine how to lay
 * out and draw components.//from ww  w  . j av  a 2  s .  c  o m
 * <p>
 * At construction time, a component's orientation is set to
 * ComponentOrientation.UNKNOWN, indicating that it has not been specified
 * explicitly. The UNKNOWN orientation behaves the same as
 * ComponentOrientation.LEFT_TO_RIGHT.
 *
 * @param o
 *            The component orientation.
 */
public void setComponentOrientation(ComponentOrientation o) {
    super.setComponentOrientation(o);
    _ltr = o.isLeftToRight();
    calculateStartPosition();
}

From source file:net.sf.vfsjfilechooser.filepane.VFSFilePane.java

/**
 * @param index visual index of the file to be edited
 *//*www .  j  a  v  a  2 s .  co  m*/
@SuppressWarnings("deprecation")
private void editFileName(int index) {
    FileObject currentDirectory = getFileChooser().getCurrentDirectory();

    if (readOnly || !canWrite(currentDirectory)) {
        return;
    }

    ensureIndexIsVisible(index);

    switch (viewType) {
    case VIEWTYPE_LIST:
        editFile = (FileObject) getModel().getElementAt(index);

        Rectangle r = list.getCellBounds(index, index);

        if (editCell == null) {
            editCell = new JTextField();

            editCell.addActionListener(new EditActionListener());
            editCell.addFocusListener(editorFocusListener);
            editCell.setNextFocusableComponent(list);
        }

        list.add(editCell);
        editCell.setText(getFileChooser().getName(editFile));

        ComponentOrientation orientation = list.getComponentOrientation();
        editCell.setComponentOrientation(orientation);

        if (orientation.isLeftToRight()) {
            editCell.setBounds(editX + r.x, r.y, r.width - editX, r.height);
        } else {
            editCell.setBounds(r.x, r.y, r.width - editX, r.height);
        }

        editCell.requestFocus();
        editCell.selectAll();

        break;

    case VIEWTYPE_DETAILS:
        detailsTable.editCellAt(index, COLUMN_FILENAME);

        break;
    }
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

/**
 * @param index visual index of the file to be edited
 *///  w w w .j  av a 2 s  .  c o  m
@SuppressWarnings("deprecation")
private void editFileName(int index) {
    FileObject currentDirectory = getFileChooser().getCurrentDirectoryObject();

    if (readOnly || !canWrite(currentDirectory)) {
        return;
    }

    ensureIndexIsVisible(index);

    switch (viewType) {
    case VIEWTYPE_LIST:
        editFile = (FileObject) getModel().getElementAt(index);

        Rectangle r = list.getCellBounds(index, index);

        if (editCell == null) {
            editCell = new JTextField();

            editCell.addActionListener(new EditActionListener());
            editCell.addFocusListener(editorFocusListener);
            editCell.setNextFocusableComponent(list);
        }

        list.add(editCell);
        editCell.setText(getFileChooser().getName(editFile));

        ComponentOrientation orientation = list.getComponentOrientation();
        editCell.setComponentOrientation(orientation);

        if (orientation.isLeftToRight()) {
            editCell.setBounds(editX + r.x, r.y, r.width - editX, r.height);
        } else {
            editCell.setBounds(r.x, r.y, r.width - editX, r.height);
        }

        editCell.requestFocus();
        editCell.selectAll();

        break;

    case VIEWTYPE_DETAILS:
        detailsTable.editCellAt(index, COLUMN_FILENAME);

        break;
    }
}