code: @Override
      public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
          float x2 = (width - component.getWidth()) * component.getAlignmentX() + x;
          float y2 = (height - component.getHeight()) * component.getAlignmentY() + y;
          component.setLocation((int) x2, (int) y2);
      }
docs: In this case a real component is to be painted. Setting the location
  of the component will cause it to be painted at that location.