ComponentOrientation co = getComponentOrientation(container);  if (!co.isLeftToRight()) x = d.width - x - w;
if (isRightToLeft) x = d.width - x - w + insets.left - insets.right;
public void layoutContainer (Container container){    // Calculate sizes if container has changed size or components were added    Dimension d = container.getSize();    if (dirty || (d.width != oldWidth) || (d.height != oldHeight))        calculateSize(container);    // Get components    Component component[] = container.getComponents();    // Layout components    for (int counter = 0; counter < component.length; counter++)    {        try        {            // Get the entry for the next component            ListIterator iterator = list.listIterator(0);            Entry entry = null;            while (iterator.hasNext())            {                entry = (Entry) iterator.next();                if (entry.component == component[counter])                    break;                else                    entry = null;            }            // Skip any components that have not been place in a specific cell,            // setting the skip component's bounds to zero            if (entry == null)            {                component[counter].setBounds(0, 0, 0, 0);                continue;            }            // The following block of code has been optimized so that the            // preferred size of the component is only obtained if it is            // needed.  There are components in which the getPreferredSize            // method is extremely expensive, such as data driven controls            // with a large amount of data.            // Get the preferred size of the component            int preferredWidth = 0;            int preferredHeight = 0;            if ((entry.alignment[C] != FULL) || (entry.alignment[R] != FULL))            {                Dimension preferredSize =                    component[counter].getPreferredSize();                preferredWidth = preferredSize.width;                preferredHeight = preferredSize.height;            }            // Calculate the coordinates and size of the component            int value[] = calculateSizeAndOffset(entry, preferredWidth, true);            int x = value[0];            int w = value[1];            value = calculateSizeAndOffset(entry, preferredHeight, false);            int y = value[0];            int h = value[1];                        // Compensate for component orientation.            ComponentOrientation co = getComponentOrientation(container);            if (!co.isLeftToRight())                x = d.width - x - w;                       // Move and resize component            component[counter].setBounds(x, y, w, h);        }        catch (Exception error)        {            // If any error occurs, set the bounds of this component to zero            // and continue            component[counter].setBounds(0, 0, 0, 0);            continue;        }    }}