本文整理汇总了Java中javax.swing.JSplitPane.setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:Java JSplitPane.setMinimumSize方法的具体用法?Java JSplitPane.setMinimumSize怎么用?Java JSplitPane.setMinimumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSplitPane
的用法示例。
在下文中一共展示了JSplitPane.setMinimumSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureFirstComponent
import javax.swing.JSplitPane; //导入方法依赖的package包/类
private void configureFirstComponent() {
JSplitPane firstSplit = (JSplitPane) getFirstComponent();
int newWidth;
int newHeight;
newWidth = firstSplit.getMinimumSize().width;
newHeight = 0;
if (getFirstComponent(firstSplit).isVisible() && getSecondComponent(firstSplit).isVisible()) {
newHeight = getFirstComponent(firstSplit).getSize().height
+ getSecondComponent(firstSplit).getMinimumSize().height + firstSplit.getDividerSize();
} else if (getFirstComponent(firstSplit).isVisible()) {
newHeight = getFirstComponent(firstSplit).getMinimumSize().height;
} else {
newHeight = getSecondComponent(firstSplit).getMinimumSize().height;
}
firstSplit.setMinimumSize(new Dimension(newWidth, newHeight));
}
示例2: configureSecondComponent
import javax.swing.JSplitPane; //导入方法依赖的package包/类
private void configureSecondComponent() {
JSplitPane secondSplit = (JSplitPane) getSecondComponent();
int newWidth = secondSplit.getMinimumSize().width;
int newHeight = 0;
if (getFirstComponent(secondSplit).isVisible() && getSecondComponent(secondSplit).isVisible()) {
newHeight = getSecondComponent(secondSplit).getSize().height
+ (getFirstComponent(secondSplit).isVisible()
? (getFirstComponent(secondSplit).getMinimumSize().height + secondSplit.getDividerSize()) : 0);
} else if (getFirstComponent(secondSplit).isVisible()) {
newHeight = getFirstComponent(secondSplit).getMinimumSize().height;
} else {
newHeight = getSecondComponent(secondSplit).getMinimumSize().height;
}
secondSplit.setMinimumSize(new Dimension(newWidth, newHeight));
}
示例3: SmileDemo
import javax.swing.JSplitPane; //导入方法依赖的package包/类
public SmileDemo() {
super(new GridLayout(1,0));
//Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Smile");
createNodes(top);
//Create a tree that allows one selection at a time.
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
//Listen for when the selection changes.
tree.addTreeSelectionListener(this);
//Create the scroll pane and add the tree to it.
JScrollPane treeView = new JScrollPane(tree);
JPanel placeholder = new JPanel(new BorderLayout());
placeholder.setBackground(Color.white);
//Create the log pane.
logPane = new JTextArea();
logPane.setEditable(false);
JScrollPane logView = new JScrollPane(logPane);
redirectSystemStreams();
workspace = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
workspace.setTopComponent(placeholder);
workspace.setBottomComponent(logView);
workspace.setDividerLocation(700);
//Add the scroll panes to a split pane.
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(treeView);
splitPane.setRightComponent(workspace);
Dimension minimumSize = new Dimension(100, 50);
placeholder.setMinimumSize(minimumSize);
logView.setMinimumSize(minimumSize);
workspace.setMinimumSize(minimumSize);
treeView.setMinimumSize(minimumSize);
splitPane.setDividerLocation(300);
splitPane.setPreferredSize(new Dimension(1000, 800));
//Add the split pane to this panel.
add(splitPane);
}