public static Alignment get(JComponent component) {
      if (component != null) {
        Object property = component.getClientProperty(Alignment.class);
        if (property instanceof Alignment alignment) return alignment;

        Container parent = component.getParent();
        if (parent instanceof JScrollPane pane) {
          if (component == pane.getColumnHeader()) {
            return TOP;
          }
          if (component == pane.getHorizontalScrollBar()) {
            return BOTTOM;
          }
          boolean ltr = pane.getComponentOrientation().isLeftToRight();
          if (component == pane.getVerticalScrollBar()) {
            return ltr ? RIGHT : LEFT;
          }
          if (component == pane.getRowHeader()) {
            return ltr ? LEFT : RIGHT;
          }
        }
        // assume alignment for a scroll bar,
        // which is not contained in a scroll pane
        if (component instanceof JScrollBar bar) {
          return switch (bar.getOrientation()) {
            case Adjustable.HORIZONTAL -> BOTTOM;
            case Adjustable.VERTICAL -> bar.getComponentOrientation().isLeftToRight() ? RIGHT : LEFT;
            default -> null;
          };
        }
      }
      return null;
    }
public static Alignment get(JComponent component)