SplittablePane extends JPanel { public void saveDividerLocation() { if (isSplit()) { dividerLocation = splitPane.getDividerLocation(); } } 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; }
@Test public void testSaveDividerLocation() throws Exception { SplittablePane splitPane = new SplittablePane(SplittablePane.HORIZONTAL_SPLIT, main, secondary); splitPane.setSize(200, 100); content.add(splitPane, BorderLayout.CENTER); content.doLayout(); splitPane.showSplit(); splitPane.saveDividerLocation(); assertEquals(splitPane.getDividerFraction(), SplittablePane.DEFAULT_DIVIDER_LOCATION, 0.1); splitPane.setDividerFraction(0.4); splitPane.saveDividerLocation(); assertEquals(splitPane.getDividerFraction(), 0.3, 0.1); splitPane.hideSplit(); splitPane.saveDividerLocation(); assertEquals(splitPane.getDividerFraction(), 0.3, 0.1); }