📄 splitpane.html
字号:
<p><table border=1><caption><a name="settingupapi">Setting Up the Split Pane</a></caption><tr><th>Method or Constructor</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#JSplitPane()">JSplitPane()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#JSplitPane(int)">JSplitPane(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#JSplitPane(int, boolean)">JSplitPane(int, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#JSplitPane(int, java.awt.Component, java.awt.Component)">JSplitPane(int, Component, Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#JSplitPane(int, boolean, java.awt.Component, java.awt.Component)">JSplitPane(int, boolean, Component, Component)</a> </td> <td>Create a split pane. When present, the <code>int</code> parameter indicates the split pane's orientation, either <code>HORIZONTAL_SPLIT</code> (the default) or <code>VERTICAL_SPLIT</code>. The <code>boolean</code> parameter, when present, sets whether the components continually repaint as the user drags the split pane. If left unspecified, this option (called <em>continuous layout</em>) is turned off. The <code>Component</code> parameters set the initial left and right, or top and bottom components, respectively. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setOrientation(int)">void setOrientation(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getOrientation()">int getOrientation()</a> </td> <td>Set or get the split pane's orientation. Use either <code>HORIZONTAL_SPLIT</code> or <code>VERTICAL_SPLIT</code> defined in <code>JSplitPane</code>. If left unspecified, the split pane will be horizontally split. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setDividerSize(int)">void setDividerSize(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getDividerSize()">int getDividerSize()</a> </td> <td>Set or get the size of the divider in pixels. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setContinuousLayout(boolean)">void setContinuousLayout(boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#isContinuousLayout()">boolean isContinuousLayout()</a> </td> <td>Set or get whether the split pane's components are continually layed out and painted while the user is dragging the divider. By default, continuous layout is turned off. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setOneTouchExpandable(boolean)">void setOneTouchExpandable(boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#isOneTouchExpandable()">boolean isOneTouchExpandable()</a> </td> <td>Set or get whether the split pane displays a control on the divider to expand/collapse the divider. The default depends on the look and feel. In the Java look and feel, it's off by default. </td> </tr></table> <p><table border=1><caption><a name="contentsapi">Managing the Split Pane's Contents</a></caption><tr><th>Method</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setTopComponent(java.awt.Component)">void setTopComponent(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setBottomComponent(java.awt.Component)">void setBottomComponent(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setLeftComponent(java.awt.Component)">void setLeftComponent(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setRightComponent(java.awt.Component)">void setRightComponent(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getTopComponent()">Component getTopComponent()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getBottomComponent()">Component getBottomComponent()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getLeftComponent()">Component getLeftComponent()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getRightComponent()">Component getRightComponent()</a> </td> <td>Set or get the indicated component. Each method works regardless of the split pane's orientation. Top and left are equivalent, and bottom and right are equivalent. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#remove(java.awt.Component)">void remove(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#removeAll()">void removeAll()</a> </td> <td>Remove the indicated component(s) from the split pane. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#add(java.awt.Component)">void add(Component)</a> </td> <td>Add the component to the split pane. You can add only two components to a split pane. The first component added is the top/left component. The second component added is the bottom/right component. Any attempt to add more components results in an exception. </td> </tr></table><p><table border=1><caption><a name="dividerapi">Positioning the Divider</a></caption><tr><th>Method</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setDividerLocation(double)">void setDividerLocation(double)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setDividerLocation(int)">void setDividerLocation(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getDividerLocation()">int getDividerLocation()</a> </td> <td>Set or get the current divider location. When setting the divider location, you can specify the new location as a percentage (<code>double</code>) or a pixel location (<code>int</code>).<br> </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#resetToPreferredSizes()">void resetToPreferredSizes()</a> </td> <td>Move the divider such that both components are at their preferred sizes. This is how a split pane divides itself at startup, unless specified otherwise. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setLastDividerLocation(int)">void setLastDividerLocation(int)</a> <br> <a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getLastDividerLocation()">int getLastDividerLocation()</a> </td> <td>Set or get the previous position of the divider. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getMaximumDividerLocation()">int getMaximumDividerLocation()</a> <br> <a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getMinimumDividerLocation()">int getMinimumDividerLocation()</a> </td> <td>Get the minimum and maximum locations for the divider. These are set implicitly by setting the minimum sizes of the split pane's two components. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#setResizeWeight(float)">void setResizeWeight(float)</a> <br> <a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSplitPane.html#getResizeWeight()">float getResizeWeight()</a> </td> <td>Set or get the resize weight for the split pane, a value between 0.0 (the default) and 1.0. See <a href="#divider">Positioning the Divider and Restricting Its Range</a> for an explanation of and examples of using the resize weight. </td> </tr></table></blockquote><h3><a name="eg">Examples that Use Split Panes</a></h3><blockquote>This table shows some examples that use <code>JSplitPane</code>and where those examples are described.<p><table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr><td> <a href="examples/index.html#SplitPaneDemo"><code>SplitPaneDemo</code></a></td><td> This page and <a href="list.html">How to Use Lists</a></td><td> Shows a split pane with a horizontal split.</td></tr><tr><td> <a href="examples/index.html#SplitPaneDividerDemo"><code>SplitPaneDividerDemo</code></a></td><td> This page</td><td> Demonstrates how component size information and resize weight are used to position the divider.</td></tr><tr><td> <a href="examples/index.html#SplitPaneDemo2"><code>SplitPaneDemo2</code></a></td><td> This page</td><td> Puts a split pane within a split pane to create a three-way split.</td></tr><tr><td> <a href="examples/index.html#TreeDemo"><code>TreeDemo</code></a></td><td> <a href="tree.html">How to Use Trees</a></td><td> Uses a split pane with a vertical split to separate a tree (in a scroll pane) from an editor pane (in a scroll pane). Does not use the one-touch expandable feature.</td></tr><tr><td> <a href="examples/index.html#TextComponentDemo"><code>TextComponentDemo</code></a></td><td> <a href="generaltext.html">Text Component Features</a></td><td> Uses a split pane with a vertical split to separate a text pane and a text area, both in scroll panes.</td></tr><tr><td> <a href="examples/index.html#TextSamplerDemo"><code>TextSamplerDemo</code></a></td><td> <a href="generaltext.html">Text Component Features</a></td><td> Uses a split pane with a vertical split and resize weight of 0.5 to separate a text pane and an editor pane, both in scroll panes. The split pane is in the right half of a container that has a fairly complicated layout. Layout managers such as <code>GridLayout</code> and <code>BorderLayout</code> are used, along with the split pane's resize weight, to ensure that the components in scroll panes share all extra space.</td></tr><tr><td> <a href="../events/examples/index.html#ListSelectionDemo"><code>ListSelectionDemo</code></a></td><td> <a class="TutorialLink" target="_top" href="../events/listselectionlistener.html">How to Write a List Selection Listener</a></td><td> Uses a split pane with a vertical split to separate an upper pane, containing a list and a table (both in scroll panes), from a lower pane that contains a combo box above a scroll pane. The lower pane uses a border layout to keep the combo box small and the scroll pane greedy for space.</td></tr></table> </blockquote> <div class=NavBit> <a target=_top href=spinner.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=tabbedpane.html>Next »</a> </div> </div> <div id=Footer><div id=TagNotes> Problems with the examples? Try <a target="_blank" href=../../information/run-examples.html>Compiling and Running the Examples: FAQs</a>. <br> Complaints? Compliments? Suggestions? <a target="_blank" href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give us your feedback</a>.<br><br> <a target="_blank" href="../../information/copyright.html">Copyright</a> 1995-2006 Sun Microsystems, Inc. All rights reserved. <span id=Download></span></div> </div> <div class=PrintHeaders> <b>Previous page:</b> How to Use Spinners <br><b>Next page:</b> How to Use Tabbed Panes </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -