}
final JSplitPane pane = (JSplitPane)root;
final Component component1 = pane.getTopComponent();
final Component component2 = pane.getBottomComponent();
final int orientation = pane.getOrientation();
final Splitter splitter = new Splitter(orientation == JSplitPane.VERTICAL_SPLIT);
splitter.setFirstComponent((JComponent) component1);
splitter.setSecondComponent((JComponent) component2);
splitter.setShowDividerControls(pane.isOneTouchExpandable());
splitter.setHonorComponentsMinimumSize(true);
// let the component chance to resize itself
SwingUtilities.invokeLater(new Runnable() {
public void run() {
double proportion;
if (pane.getOrientation() == JSplitPane.VERTICAL_SPLIT) {
proportion = pane.getDividerLocation() / (double)(parent.getHeight() - pane.getDividerSize());
}
else {
proportion = pane.getDividerLocation() / (double)(parent.getWidth() - pane.getDividerSize());
}
if (proportion > 0 && proportion < 1) {
splitter.setProportion((float)proportion);
}
}
});
if (parent instanceof Splitter) {
final Splitter psplitter = (Splitter) parent;
if (psplitter.getFirstComponent() == root)
psplitter.setFirstComponent(splitter);
else
psplitter.setSecondComponent(splitter);
}
else {
parent.remove(0);
parent.setLayout(new BorderLayout());
parent.add(splitter, BorderLayout.CENTER);