@Test public void testSetMainComponent() { SplittablePane splitPane; JLabel other = new JLabel("other");; splitPane = new SplittablePane(SplittablePane.HORIZONTAL_SPLIT, main, secondary); splitPane.setSize(200, 100); assertEquals(splitPane.getMainComponent(), main); splitPane.setMainComponent(other); assertEquals(splitPane.getMainComponent(), other); splitPane = new SplittablePane(SplittablePane.HORIZONTAL_SPLIT, null); assertEquals(splitPane.getMainComponent(), null); splitPane.setMainComponent(other); assertEquals(splitPane.getMainComponent(), other); splitPane.showSplit(); assertTrue(splitPane.isSplit()); assertEquals(splitPane.getMainComponent(), other); splitPane.setMainComponent(secondary); assertEquals(splitPane.getMainComponent(), secondary); splitPane = new SplittablePane(SplittablePane.VERTICAL_SPLIT, main, secondary); assertEquals(splitPane.getMainComponent(), main); splitPane.showSplit(); assertTrue(splitPane.isSplit()); splitPane.setMainComponent(other); assertEquals(splitPane.getMainComponent(), other); }
public void setMainComponent(Component component) { if (!isSplit()) { if (mainComponent != null) { remove(mainComponent); } if (component != null) { add(component, BorderLayout.CENTER); } } else { if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { splitPane.setLeftComponent(component); } else { splitPane.setTopComponent(component); } } mainComponent = component; }
SplittablePane extends JPanel { public void setMainComponent(Component component) { if (!isSplit()) { if (mainComponent != null) { remove(mainComponent); } if (component != null) { add(component, BorderLayout.CENTER); } } else { if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { splitPane.setLeftComponent(component); } else { splitPane.setTopComponent(component); } } mainComponent = component; } }
SplittablePane extends JPanel { public void setMainComponent(Component component) { if (!isSplit()) { if (mainComponent != null) { remove(mainComponent); } if (component != null) { add(component, BorderLayout.CENTER); } } else { if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { splitPane.setLeftComponent(component); } else { splitPane.setTopComponent(component); } } mainComponent = component; } SplittablePane();  SplittablePane(int orientation, Component mainComponent);  SplittablePane(int orientation, Component mainComponent, Component secondaryComponent); }
SplittablePane extends JPanel { public void setMainComponent(Component component) { if (!isSplit()) { if (mainComponent != null) { remove(mainComponent); } if (component != null) { add(component, BorderLayout.CENTER); } } else { if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { splitPane.setLeftComponent(component); } else { splitPane.setTopComponent(component); } } mainComponent = component; } SplittablePane();  SplittablePane(int orientation, Component mainComponent);  SplittablePane(int orientation, Component mainComponent, Component secondaryComponent); void setMainComponent(Component component); void setSecondaryComponent(Component secondaryComponent); void hideSplit(); void showSplit(); void saveDividerLocation(); boolean isSplit(); Component getMainComponent(); Component getSecondaryComponent(); void setDividerFraction(double fraction); double getDividerFraction(); @Override void setSize(int width, int height); }
SplittablePane extends JPanel { public void setMainComponent(Component component) { if (!isSplit()) { if (mainComponent != null) { remove(mainComponent); } if (component != null) { add(component, BorderLayout.CENTER); } } else { if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { splitPane.setLeftComponent(component); } else { splitPane.setTopComponent(component); } } mainComponent = component; } SplittablePane();  SplittablePane(int orientation, Component mainComponent);  SplittablePane(int orientation, Component mainComponent, Component secondaryComponent); void setMainComponent(Component component); void setSecondaryComponent(Component secondaryComponent); void hideSplit(); void showSplit(); void saveDividerLocation(); boolean isSplit(); Component getMainComponent(); Component getSecondaryComponent(); void setDividerFraction(double fraction); double getDividerFraction(); @Override void setSize(int width, int height); static final int HORIZONTAL_SPLIT; static final int VERTICAL_SPLIT; static final double DEFAULT_DIVIDER_LOCATION; }