Example usage for java.awt Component getComponentOrientation

List of usage examples for java.awt Component getComponentOrientation

Introduction

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

Prototype

public ComponentOrientation getComponentOrientation() 

Source Link

Document

Retrieves 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 boolean isLeftToRight(Component c) {
    return c.getComponentOrientation().isLeftToRight();
}

From source file:Main.java

static boolean isLeftToRight(Component c) {
    return c.getComponentOrientation().isLeftToRight();
}

From source file:Main.java

public static boolean isLeftToRight(Component c) {
    return c == null || c.getComponentOrientation().isLeftToRight();
}

From source file:Main.java

/**
 * Copies component orientation from one component to another.
 *
 * @param from//from   www .  j  a v  a2 s . c o 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:Main.java

/**
 * Returns true if the given point is within the actual bounds of the
 * JList item at index (not just inside the cell).
 *//*www. j  ava  2  s  .co m*/
private static boolean pointIsInActualBounds(JList list, int index, Point point) {
    ListCellRenderer renderer = list.getCellRenderer();
    ListModel dataModel = list.getModel();
    Object value = dataModel.getElementAt(index);
    Component item = renderer.getListCellRendererComponent(list, value, index, false, false);
    Dimension itemSize = item.getPreferredSize();
    Rectangle cellBounds = list.getCellBounds(index, index);
    if (!item.getComponentOrientation().isLeftToRight()) {
        cellBounds.x += (cellBounds.width - itemSize.width);
    }
    cellBounds.width = itemSize.width;

    return cellBounds.contains(point);
}

From source file:Main.java

/**
 *
 * @param list//from   w  w w. j  a  v  a 2  s. c  om
 * @param index
 * @param point
 * @return
 */
public static boolean pointIsInActualBounds(JList list, int index, Point point) {
    ListCellRenderer renderer = list.getCellRenderer();
    ListModel dataModel = list.getModel();
    Object value = dataModel.getElementAt(index);
    Component item = renderer.getListCellRendererComponent(list, value, index, false, false);
    Dimension itemSize = item.getPreferredSize();
    Rectangle cellBounds = list.getCellBounds(index, index);

    if (!item.getComponentOrientation().isLeftToRight()) {
        cellBounds.x += (cellBounds.width - itemSize.width);
    }

    cellBounds.width = itemSize.width;

    return cellBounds.contains(point);
}

From source file:com.openbravo.pos.epm.JEmployeeFinder.java

/**
 *
 * @param parent/*from  w  w  w  .j av a  2  s  .c o m*/
 * @param dlPresenceManagement
 * @return
 */
public static JEmployeeFinder getEmployeeFinder(Component parent,
        DataLogicPresenceManagement dlPresenceManagement) {
    Window window = getWindow(parent);
    JEmployeeFinder myMsg;
    if (window instanceof Frame) {
        myMsg = new JEmployeeFinder((Frame) window, true);
    } else {
        myMsg = new JEmployeeFinder((Dialog) window, true);
    }
    myMsg.init(dlPresenceManagement);
    myMsg.applyComponentOrientation(parent.getComponentOrientation());
    return myMsg;
}

From source file:com.openbravo.pos.customers.JCustomerFinder.java

/**
 *
 * @param parent//from ww w .j  a v  a  2  s .co  m
 * @param dlCustomers
 * @return
 */
public static JCustomerFinder getCustomerFinder(Component parent, DataLogicCustomers dlCustomers) {
    Window window = getWindow(parent);

    JCustomerFinder myMsg;
    if (window instanceof Frame) {
        myMsg = new JCustomerFinder((Frame) window, true);
    } else {
        myMsg = new JCustomerFinder((Dialog) window, true);
    }
    myMsg.init(dlCustomers);
    myMsg.applyComponentOrientation(parent.getComponentOrientation());
    return myMsg;
}

From source file:com.openbravo.pos.panels.JTicketsFinder.java

/**
 *
 * @param parent/*from w w  w. j a v  a 2 s .  com*/
 * @param dlSales
 * @param dlCustomers
 * @return
 */
public static JTicketsFinder getReceiptFinder(Component parent, DataLogicSales dlSales,
        DataLogicCustomers dlCustomers) {
    Window window = getWindow(parent);

    JTicketsFinder myMsg;
    if (window instanceof Frame) {
        myMsg = new JTicketsFinder((Frame) window, true);
    } else {
        myMsg = new JTicketsFinder((Dialog) window, true);
    }
    myMsg.init(dlSales, dlCustomers, parent);
    myMsg.applyComponentOrientation(parent.getComponentOrientation());
    return myMsg;
}