下面列出了javax.swing.JSplitPane#resetToPreferredSizes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JSplitPane createSplitPane() {
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setOneTouchExpandable(true);
splitPane.setLeftComponent(new JScrollPane(imagePanel));
splitPane.setRightComponent(getAnnotationPanel());
splitPane.resetToPreferredSizes();
return splitPane;
}
/**
* Overridden to handle our layout requirements
*/
public void doLayout() {
Component[] c = getComponents();
if (c.length > 0 && getWidth() >= 0 && getHeight() >= 0) {
Insets ins = getInsets();
c[0].setBounds(ins.left, ins.top, getWidth() - (ins.right + ins.left), getHeight() - ins.top + ins.bottom);
if (c[0] instanceof JSplitPane && Boolean.TRUE.equals(firstSplit)) {
JSplitPane pane = (JSplitPane) c[0];
pane.setDividerLocation(0.80f);
pane.resetToPreferredSizes();
JComponent dc = findDescriptionComponent();
if (dc != null) {
if (dc.getHeight() > 0) {
firstSplit = Boolean.FALSE;
}
} else {
firstSplit = Boolean.FALSE;
}
}
if (c.length > 1) {
throw new IllegalStateException("Hmm, something is wrong: " + Arrays.asList(c));
}
}
}