本文整理汇总了Java中javax.swing.JScrollPane.setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollPane.setMinimumSize方法的具体用法?Java JScrollPane.setMinimumSize怎么用?Java JScrollPane.setMinimumSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollPane
的用法示例。
在下文中一共展示了JScrollPane.setMinimumSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCommitMessageTextArea
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void addCommitMessageTextArea(GridBagConstraints gbc) {
gbc.insets = new Insets(UIConstants.COMPONENT_TOP_PADDING, UIConstants.COMPONENT_LEFT_PADDING,
UIConstants.COMPONENT_BOTTOM_PADDING, UIConstants.COMPONENT_RIGHT_PADDING);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.gridwidth = 2;
commitMessage = new JTextArea();
commitMessage.setLineWrap(true);
// Around 3 lines of text.
int fontH = commitMessage.getFontMetrics(commitMessage.getFont()).getHeight();
commitMessage.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(commitMessage);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setMinimumSize(new Dimension(10, 3 * fontH));
UndoSupportInstaller.installUndoManager(commitMessage);
this.add(scrollPane, gbc);
}
示例2: initialize
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public void initialize() {
JPanel edit = new JPanel(new GridLayout(4, 1, 0, 5));
stepsLabel = new JLabel("Steps:");
steps = new JSpinner(new SpinnerNumberModel(SPA.getNumberOfSteps(), 2, ParametricAnalysis.MAX_STEP_NUMBER, 1));
steps.setToolTipText("Sets the number of performed simulations");
edit.add(stepsLabel);
edit.add(steps);
edit.setPreferredSize(new Dimension(130, 108));
JPanel editLables = new JPanel(new GridLayout(4, 1, 0, 5));
editLables.add(stepsLabel);
editLables.setPreferredSize(new Dimension(100, 108));
JPanel editPanel = new JPanel();
editPanel.add(editLables);
editPanel.add(edit);
editPanel.setBorder(new EmptyBorder(10, 20, 0, 20));
JPanel cont = new JPanel(new BorderLayout());
title = new TitledBorder("Simulation seed variation");
cont.add(editPanel, BorderLayout.CENTER);
scroll = new JScrollPane(cont);
scroll.setBorder(title);
description = new JTextArea(DESCRIPTION);
description.setOpaque(false);
description.setEditable(false);
description.setLineWrap(true);
description.setWrapStyleWord(true);
descrPane = new JScrollPane(description);
descriptionTitle = new TitledBorder(new EtchedBorder(), "Description");
descrPane.setBorder(descriptionTitle);
descrPane.setMinimumSize(new Dimension(80, 0));
scroll.setMinimumSize(new Dimension(360, 0));
setLeftComponent(scroll);
setRightComponent(descrPane);
setListeners();
this.setBorder(new EmptyBorder(5, 0, 5, 0));
}
示例3: initialize
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public void initialize() {
JPanel edit = new JPanel(new GridLayout(4, 1, 0, 5));
stepsLabel = new JLabel("Steps (n. of exec.): ");
steps = new JSpinner(new SpinnerNumberModel(SPA.getNumberOfSteps(), 2, ParametricAnalysis.MAX_STEP_NUMBER, 1));
steps.setToolTipText("Sets the number of performed simulations");
edit.add(stepsLabel);
edit.add(steps);
edit.setPreferredSize(new Dimension(130, 88));
JPanel editLables = new JPanel(new GridLayout(4, 1, 0, 5));
editLables.add(stepsLabel);
editLables.setPreferredSize(new Dimension(100, 88));
JPanel editPanel = new JPanel();
editPanel.add(editLables);
editPanel.add(edit);
editPanel.setBorder(new EmptyBorder(10, 20, 0, 20));
JPanel cont = new JPanel(new BorderLayout());
title = new TitledBorder("Simulation seed variation");
cont.add(editPanel, BorderLayout.CENTER);
scroll = new JScrollPane(cont);
scroll.setBorder(title);
description = new JTextArea(DESCRIPTION);
description.setOpaque(false);
description.setEditable(false);
description.setLineWrap(true);
description.setWrapStyleWord(true);
descrPane = new JScrollPane(description);
descriptionTitle = new TitledBorder(new EtchedBorder(), "Description");
descrPane.setBorder(descriptionTitle);
descrPane.setMinimumSize(new Dimension(80, 0));
scroll.setMinimumSize(new Dimension(360, 0));
setLeftComponent(scroll);
setRightComponent(descrPane);
setListeners();
this.setBorder(new EmptyBorder(5, 0, 5, 0));
}
示例4: initializeComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void initializeComponents() {
filterBox = FilterLoader.getFilterBox();
fcp = getFilter().getSettingsPanel(setP.getRefreshable(), channel);
settingsPane= new JScrollPane(fcp);
settingsPane.setMinimumSize(new Dimension(fcp.getPreferredSize().width, Math.min(100, fcp.getMinimumSize().height)));
settingsPane.getViewport().setOpaque(false);
settingsPane.setBorder(BorderFactory.createEmptyBorder());
settingsPane.setOpaque(false);
}
示例5: scrollpane
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Make a JScrollPane containing the given component (which can be null),
* then apply a set of attributes to it.
*
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make
* OurUtil.make(component, attributes...)}
*/
public static JScrollPane scrollpane(Component component, Object... attributes) {
JScrollPane ans = make(new JScrollPane(), new EmptyBorder(0, 0, 0, 0));
if (component != null)
ans.setViewportView(component);
ans.setMinimumSize(new Dimension(50, 50));
return make(ans, attributes);
}
示例6: MapGeneratorOptionsDialog
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Creates a dialog to set the map generator options.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param editable Whether the options may be edited.
*/
public MapGeneratorOptionsDialog(FreeColClient freeColClient, JFrame frame,
boolean editable) {
super(freeColClient, frame, editable,
freeColClient.getGame().getMapGeneratorOptions(),
MapGeneratorOptions.TAG,
FreeColDirectories.MAP_GENERATOR_OPTIONS_FILE_NAME,
MapGeneratorOptions.TAG);
if (isEditable()) {
loadDefaultOptions();
// FIXME: The update should be solved by PropertyEvent.
final List<File> mapFiles = FreeColDirectories.getMapFileList();
JPanel mapPanel = new JPanel();
for (File f : mapFiles) {
JButton mapButton = makeMapButton(f);
if (mapButton == null) continue;
mapButton.addActionListener((ActionEvent ae) -> {
updateFile(f);
});
mapPanel.add(mapButton);
}
JScrollPane scrollPane = new JScrollPane(mapPanel,
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
scrollPane.getViewport().setOpaque(false);
// FIXME: find out how to do this properly
scrollPane.setMinimumSize(new Dimension(400, 110));
panel.add(scrollPane);
}
initialize(frame, choices());
}
示例7: scrollpane
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/** Make a JScrollPane containing the given component (which can be null), then apply a set of attributes to it.
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make OurUtil.make(component, attributes...)}
*/
public static JScrollPane scrollpane (Component component, Object... attributes) {
JScrollPane ans = make(new JScrollPane(), new EmptyBorder(0,0,0,0));
if (component!=null) ans.setViewportView(component);
ans.setMinimumSize(new Dimension(50, 50));
return make(ans, attributes);
}
示例8: adjustScrollPaneSize
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private static void adjustScrollPaneSize(JScrollPane sp, JEditorPane editorPane) {
int height;
//logger.fine("createSingleLineEditor(): editorPane's margin = "+editorPane.getMargin());
//logger.fine("createSingleLineEditor(): editorPane's insets = "+editorPane.getInsets());
Dimension prefSize = sp.getPreferredSize();
Insets borderInsets = sp.getBorder().getBorderInsets(sp);//sp.getInsets();
int vBorder = borderInsets.bottom + borderInsets.top;
EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
if (logger.isLoggable(Level.FINE)) {
logger.fine("createSingleLineEditor(): editor UI = "+eui);
if (eui != null) {
logger.fine("createSingleLineEditor(): editor UI's line height = "+eui.getLineHeight());
logger.fine("createSingleLineEditor(): editor UI's line ascent = "+eui.getLineAscent());
}
}
if (eui != null) {
height = eui.getLineHeight();
if (height < eui.getLineAscent()) {
height = (eui.getLineAscent()*4)/3; // Hack for the case when line height = 1
}
} else {
java.awt.Font font = editorPane.getFont();
java.awt.FontMetrics fontMetrics = editorPane.getFontMetrics(font);
height = fontMetrics.getHeight();
//logger.fine("createSingleLineEditor(): editor's font = "+font+" with metrics = "+fontMetrics+", leading = "+fontMetrics.getLeading());
//logger.fine("createSingleLineEditor(): font's height = "+height);
}
height += vBorder + getLFHeightAdjustment();
//height += 2; // 2 for border
if (logger.isLoggable(Level.FINE)) {
logger.fine("createSingleLineEditor(): border vertical insets = "+borderInsets.bottom+" + "+borderInsets.top);
logger.fine("createSingleLineEditor(): computed height = "+height+", prefSize = "+prefSize);
}
if (prefSize.height < height) {
prefSize.height = height;
sp.setPreferredSize(prefSize);
sp.setMinimumSize(prefSize);
sp.setMaximumSize(prefSize);
java.awt.Container c = sp.getParent();
logger.fine("createSingleLineEditor(): setting a new height of ScrollPane = "+height);
if (c instanceof JComponent) {
((JComponent) c).revalidate();
}
}
}
示例9: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout());
String modeName = stationData.getTransitionModeName(stationKey, 0);
firingBorder = new TitledBorder(new EtchedBorder(), "Firing Outcome for " + modeName);
firingTable = new FiringOutcomeTable();
firingPane = new JScrollPane(firingTable);
firingPane.setBorder(firingBorder);
firingPane.setMinimumSize(new Dimension(300, 240));
leftPanel = new WarningScrollTable(firingPane, WARNING_CLASS_OUTGOING_ROUTING);
leftPanel.addCheckVector(stationOutKeys);
leftPanel.addCheckVector(classKeys);
addModeButton = new JButton("Add Mode");
addModeButton.setMinimumSize(DIM_BUTTON_M);
modeTable = new ModeTable();
JPanel modePanel = new JPanel(new BorderLayout(5, 5));
modePanel.setBorder(new TitledBorder(new EtchedBorder(), "Modes"));
modePanel.setMinimumSize(new Dimension(200, 120));
modePanel.add(addModeButton, BorderLayout.NORTH);
modePanel.add(new JScrollPane(modeTable), BorderLayout.CENTER);
noticeText = new JTextArea("");
noticeText.setOpaque(false);
noticeText.setEditable(false);
noticeText.setLineWrap(true);
noticeText.setWrapStyleWord(true);
JScrollPane noticePane = new JScrollPane(noticeText);
noticePane.setBorder(new TitledBorder(new EtchedBorder(), "Notice"));
noticePane.setMinimumSize(new Dimension(200, 120));
JSplitPane rightPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
rightPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
rightPanel.setDividerSize(4);
rightPanel.setResizeWeight(1.0);
rightPanel.setLeftComponent(modePanel);
rightPanel.setRightComponent(noticePane);
JSplitPane mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
mainPanel.setDividerSize(4);
mainPanel.setResizeWeight(1.0);
mainPanel.setLeftComponent(leftPanel);
mainPanel.setRightComponent(rightPanel);
add(mainPanel);
}
示例10: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout());
String modeName = stationData.getTransitionModeName(stationKey, 0);
enablingBorder = new TitledBorder(new EtchedBorder(), "Enabling Condition for " + modeName);
enablingTable = new ConditionTable(true);
enablingPane = new JScrollPane(enablingTable);
enablingPane.setBorder(enablingBorder);
enablingPane.setMinimumSize(new Dimension(300, 120));
inhibitingBorder = new TitledBorder(new EtchedBorder(), "Inhibiting Condition for " + modeName);
inhibitingTable = new ConditionTable(false);
inhibitingPane = new JScrollPane(inhibitingTable);
inhibitingPane.setBorder(inhibitingBorder);
inhibitingPane.setMinimumSize(new Dimension(300, 120));
JPanel conditionPanel = new JPanel(new GridLayout(2, 1, 3, 3));
conditionPanel.add(enablingPane);
conditionPanel.add(inhibitingPane);
leftPanel = new WarningScrollTable(conditionPanel, WARNING_CLASS_INCOMING_ROUTING);
leftPanel.addCheckVector(stationInKeys);
leftPanel.addCheckVector(classKeys);
addModeButton = new JButton("Add Mode");
addModeButton.setMinimumSize(DIM_BUTTON_M);
modeTable = new ModeTable();
JPanel modePanel = new JPanel(new BorderLayout(5, 5));
modePanel.setBorder(new TitledBorder(new EtchedBorder(), "Modes"));
modePanel.setMinimumSize(new Dimension(200, 120));
modePanel.add(addModeButton, BorderLayout.NORTH);
modePanel.add(new JScrollPane(modeTable), BorderLayout.CENTER);
noticeText = new JTextArea("");
noticeText.setOpaque(false);
noticeText.setEditable(false);
noticeText.setLineWrap(true);
noticeText.setWrapStyleWord(true);
JScrollPane noticePane = new JScrollPane(noticeText);
noticePane.setBorder(new TitledBorder(new EtchedBorder(), "Notice"));
noticePane.setMinimumSize(new Dimension(200, 120));
JSplitPane rightPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
rightPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
rightPanel.setDividerSize(4);
rightPanel.setResizeWeight(1.0);
rightPanel.setLeftComponent(modePanel);
rightPanel.setRightComponent(noticePane);
JSplitPane mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
mainPanel.setDividerSize(4);
mainPanel.setResizeWeight(1.0);
mainPanel.setLeftComponent(leftPanel);
mainPanel.setRightComponent(rightPanel);
add(mainPanel);
}
示例11: initialize
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public void initialize() {
JPanel edit = new JPanel(new GridLayout(4, 1, 0, 5));
fromLabel = new JLabel("Initial ß: ");
from = new JSpinner(new SpinnerNumberModel(PMPA.getInitialValue(), 0.000, 1.000, 0.001));
from.setToolTipText("Sets the initial proportion of jobs");
toLabel = new JLabel("Final ß: ");
to = new JSpinner(new SpinnerNumberModel(PMPA.getFinalValue(), 0.000, 1.000, 0.001));
to.setToolTipText("Sets the final proportion of jobs");
stepsLabel = new JLabel("Steps (n. of exec.): ");
int maxSteps = PMPA.searchForAvailableSteps();
if (maxSteps > ParametricAnalysis.MAX_STEP_NUMBER) {
maxSteps = ParametricAnalysis.MAX_STEP_NUMBER;
}
steps = new JSpinner(new SpinnerNumberModel(PMPA.getNumberOfSteps(), 2, maxSteps, 1));
steps.setToolTipText("Sets the number of steps to be performed");
Vector<Object> classes = cd.getClosedClassKeys();
String[] classNames = new String[classes.size()];
for (int i = 0; i < classes.size(); i++) {
classNames[i] = cd.getClassName(classes.get(i));
}
classChooserLabel = new JLabel("Class: ");
classChooser = new JComboBox(classNames);
classChooser.setToolTipText("Sets the class the inserted values will refer to");
classChooser.setSelectedItem(cd.getClassName(PMPA.getReferenceClass()));
edit.add(fromLabel);
edit.add(from);
edit.add(toLabel);
edit.add(to);
edit.add(stepsLabel);
edit.add(steps);
edit.add(classChooserLabel);
edit.add(classChooser);
edit.setPreferredSize(new Dimension(130, 88));
JPanel editLables = new JPanel(new GridLayout(4, 1, 0, 5));
editLables.add(fromLabel);
editLables.add(toLabel);
editLables.add(stepsLabel);
editLables.add(classChooserLabel);
editLables.setPreferredSize(new Dimension(100, 88));
JPanel editPanel = new JPanel();
editPanel.add(editLables);
editPanel.add(edit);
editPanel.setBorder(new EmptyBorder(15, 20, 0, 20));
JPanel cont = new JPanel(new BorderLayout());
cont.add(editPanel, BorderLayout.CENTER);
scroll = new JScrollPane(cont);
title = new TitledBorder("Type of population mix");
scroll.setBorder(title);
description = new JTextArea(DESCRIPTION);
description.setOpaque(false);
description.setEditable(false);
description.setLineWrap(true);
description.setWrapStyleWord(true);
descrPane = new JScrollPane(description);
descriptionTitle = new TitledBorder(new EtchedBorder(), "Description");
descrPane.setBorder(descriptionTitle);
descrPane.setMinimumSize(new Dimension(80, 0));
scroll.setMinimumSize(new Dimension(360, 0));
setLeftComponent(scroll);
setRightComponent(descrPane);
setListeners();
this.setBorder(new EmptyBorder(5, 0, 5, 0));
}
示例12: TreeIconDemo
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public TreeIconDemo() {
super(new GridLayout(1, 0));
// Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
createNodes(top);
// Create a tree that allows one selection at a time.
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Set the icon for leaf nodes.
ImageIcon leafIcon = createImageIcon("images/middle.gif");
if (leafIcon != null) {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setLeafIcon(leafIcon);
tree.setCellRenderer(renderer);
} else {
System.err.println("Leaf icon missing; using default.");
}
// Listen for when the selection changes.
tree.addTreeSelectionListener(this);
// Create the scroll pane and add the tree to it.
JScrollPane treeView = new JScrollPane(tree);
// Create the HTML viewing pane.
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
initHelp();
JScrollPane htmlView = new JScrollPane(htmlPane);
// Add the scroll panes to a split pane.
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(treeView);
splitPane.setBottomComponent(htmlView);
Dimension minimumSize = new Dimension(100, 50);
htmlView.setMinimumSize(minimumSize);
treeView.setMinimumSize(minimumSize);
splitPane.setDividerLocation(100); // XXX: ignored in some releases
// of Swing. bug 4101306
// workaround for bug 4101306:
// treeView.setPreferredSize(new Dimension(100, 100));
splitPane.setPreferredSize(new Dimension(500, 300));
// Add the split pane to this panel.
add(splitPane);
}
示例13: TreeIconDemo2
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public TreeIconDemo2() {
super(new GridLayout(1, 0));
// Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
createNodes(top);
// Create a tree that allows one selection at a time.
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Enable tool tips.
ToolTipManager.sharedInstance().registerComponent(tree);
// Set the icon for leaf nodes.
ImageIcon tutorialIcon = createImageIcon("images/middle.gif");
if (tutorialIcon != null) {
tree.setCellRenderer(new MyRenderer(tutorialIcon));
} else {
System.err.println("Tutorial icon missing; using default.");
}
// Listen for when the selection changes.
tree.addTreeSelectionListener(this);
// Create the scroll pane and add the tree to it.
JScrollPane treeView = new JScrollPane(tree);
// Create the HTML viewing pane.
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
initHelp();
JScrollPane htmlView = new JScrollPane(htmlPane);
// Add the scroll panes to a split pane.
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(treeView);
splitPane.setBottomComponent(htmlView);
Dimension minimumSize = new Dimension(100, 50);
htmlView.setMinimumSize(minimumSize);
treeView.setMinimumSize(minimumSize);
splitPane.setDividerLocation(100); // XXX: ignored in some releases
// of Swing. bug 4101306
// workaround for bug 4101306:
// treeView.setPreferredSize(new Dimension(100, 100));
splitPane.setPreferredSize(new Dimension(500, 300));
// Add the split pane to this panel.
add(splitPane);
}
示例14: SmileDemo
import javax.swing.JScrollPane; //导入方法依赖的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);
}
示例15: TreeDemo
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public TreeDemo() {
super(new GridLayout(1,0));
//Create the nodes.
DefaultMutableTreeNode top =
new DefaultMutableTreeNode("The Java Series");
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);
if (playWithLineStyle) {
System.out.println("line style = " + lineStyle);
tree.putClientProperty("JTree.lineStyle", lineStyle);
}
//Create the scroll pane and add the tree to it.
JScrollPane treeView = new JScrollPane(tree);
//Create the HTML viewing pane.
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
initHelp();
JScrollPane htmlView = new JScrollPane(htmlPane);
//Add the scroll panes to a split pane.
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(treeView);
splitPane.setBottomComponent(htmlView);
Dimension minimumSize = new Dimension(100, 50);
htmlView.setMinimumSize(minimumSize);
treeView.setMinimumSize(minimumSize);
splitPane.setDividerLocation(100);
splitPane.setPreferredSize(new Dimension(500, 300));
//Add the split pane to this panel.
add(splitPane);
}