if (orientation.isLeftToRight()) x = rectIn.x + (rectIn.width - width);
if (textField.getComponentOrientation().isLeftToRight()) x = rectIn.x + (rectIn.width - width - 1);
  protected Shape adjustAllocation(Shape shape)  {    Rectangle rectIn = shape.getBounds();    // vertical adjustment    int height = (int) getPreferredSpan(Y_AXIS);    int y = rectIn.y + (rectIn.height - height) / 2;    // horizontal adjustment    JTextField textField = (JTextField) getContainer();    int halign = textField.getHorizontalAlignment();    int width = (int) getPreferredSpan(X_AXIS);    int x;    ComponentOrientation orientation = textField.getComponentOrientation();    switch (halign)      {      case JTextField.CENTER:        x = rectIn.x + (rectIn.width - width) / 2;        break;      case JTextField.RIGHT:        x = rectIn.x + (rectIn.width - width);        break;      case JTextField.TRAILING:        if (orientation.isLeftToRight())          x = rectIn.x + (rectIn.width - width);        else          x = rectIn.x;        break;      case JTextField.LEADING:        if (orientation.isLeftToRight())          x = rectIn.x;        else          x = rectIn.x + (rectIn.width - width);        break;      case JTextField.LEFT:      default:        x = rectIn.x;        break;      }    return new Rectangle(x, y, width, height);  }