Replacing components resets alignment etc

When replacing components in an AbstractOrderedLayout, is there a way to preserve (or automatically copy from the old component) alignment, expand ratio and other stylistic information?

Now I’m redoing all the alignments each time i replace the components:


public void myReplaceComponent(Component old, Component new) {
  layout.replaceComponent(old, new);
  layout.setComponentAlignment(new, Alignment.MIDDLE_CENTER);
  layout.setExpandRatio(new, 1);
}