⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 visual.html

📁 jsf、swing的官方指南
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    function toggleLeft() {        showLeft(document.getElementById("LeftBar").className ==                "LeftBar_hidden");        document.getElementById("ToggleLeft").blur();    }    function load() {        showLeft(leftBar());        document.getElementById("ToggleLeft").style.display="inline";    }    </script>    </head><body onload="load()">    <div id=TopBar> <div id=TopBar_tr> <div id=TopBar_tl> <div id=TopBar_br> <div id=TopBar_bl>                         <div id=TopBar_right>                             <a target="_blank"                                href="http://java.sun.com/javase/6/download.jsp">Download                                the JDK</a>                            <br>                            <a href="../../search.html" target="_blank">Search the                                Tutorials</a>                            <br>                            <a href="javascript:toggleLeft()"                                id="ToggleLeft">Hide the TOC</a>                        </div>                    </div> </div> </div> </div> </div>    <div class=PrintHeaders>        <b>Trail:</b> Creating a GUI with JFC/Swing        <br><b>Lesson:</b> Laying Out Components Within a Container    </div>    <div id=LeftBar class=LeftBar_shown>        <div id=Contents>            <div class="linkLESSON"><a href="index.html">Laying Out Components Within a Container</a></div><div class="nolinkAHEAD">A Visual Guide to Layout Managers</div><div class="linkAHEAD"><a href="using.html">Using Layout Managers</a></div><div class="linkAHEAD"><a href="howLayoutWorks.html">How Layout Management Works</a></div><div class="linkAHEAD"><a href="layoutlist.html">How to Use Various Layout Managers</a></div><div class="linkAHEAD"><a href="border.html">How to Use BorderLayout</a></div><div class="linkAHEAD"><a href="box.html">How to Use BoxLayout</a></div><div class="linkAHEAD"><a href="card.html">How to Use CardLayout</a></div><div class="linkAHEAD"><a href="flow.html">How to Use FlowLayout</a></div><div class="linkAHEAD"><a href="gridbag.html">How to Use GridBagLayout</a></div><div class="linkAHEAD"><a href="grid.html">How to Use GridLayout</a></div><div class="linkAHEAD"><a href="group.html">How to Use GroupLayout</a></div><div class="linkBHEAD"><a href="groupExample.html">A GroupLayout Example</a></div><div class="linkAHEAD"><a href="spring.html">How to Use SpringLayout</a></div><div class="linkAHEAD"><a href="custom.html">Creating a Custom Layout Manager</a></div><div class="linkAHEAD"><a href="none.html">Doing Without a Layout Manager (Absolute Positioning)</a></div><div class="linkAHEAD"><a href="problems.html">Solving Common Layout Problems</a></div></div>    </div>    <div id=MainFlow class=MainFlow_indented>            <span id=BreadCrumbs>                <a href=../../index.html target=_top>Home Page</a>                &gt;                <a href=../index.html target=_top>Creating a GUI with JFC/Swing</a>                &gt;                <a href=index.html target=_top>Laying Out Components Within a Container</a>            </span>            <div class=NavBit>                <a target=_top href=index.html>&laquo;&nbsp;Previous</a>&nbsp;&bull;&nbsp;<a target=_top href=../TOC.html>Trail</a>&nbsp;&bull;&nbsp;<a target=_top href=using.html>Next&nbsp;&raquo;</a>            </div>            <div id=PageTitle>A Visual Guide to Layout Managers</div>            <blockquote><p>Several AWT and Swing classes provide layout managers for general use:<ul><li> <a href="#border"><code>BorderLayout</code></a><li> <a href="#box"><code>BoxLayout</code></a><li> <a href="#card"><code>CardLayout</code></a><li> <a href="#flow"><code>FlowLayout</code></a><li> <a href="#gridbag"><code>GridBagLayout</code></a><li> <a href="#grid"><code>GridLayout</code></a><li> <a href="#spring"><code>SpringLayout</code></a></ul><p>This section shows example GUIsthat use these layout managers,and tells you where to find the how-to page for each layout manager.You can find links for running the examplesin the how-to pages and the<a href="examples/index.html">example index</a>.</blockquote><a name="border"><h3>BorderLayout</h3></a><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/BorderLayoutDemo.png" WIDTH="482" HEIGHT="186" ALIGN="BOTTOM" ALT="A picture of a GUI that uses BorderLayout"></center></p></a>Every content paneis initialized to use a <code>BorderLayout</code>.(As<a class="TutorialLink" target="_top" href="../components/toplevel.html">Using Top-Level Containers</a> explains,the content pane is the main container in all frames, applets, and dialogs.)A <code>BorderLayout</code>places components in up to five areas:top, bottom, left, right, and center.All extra space is placed in the center area.For further details, see<a href="border.html">How to Use BorderLayout</a>.</blockquote><h3><a name="box">BoxLayout</a></h3><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/BoxLayoutDemo.png" WIDTH="203" HEIGHT="164" ALIGN="BOTTOM" ALT="A picture of a GUI that uses BoxLayout"></center></p>The <code>BoxLayout</code> class puts componentsin a single row or column.It respects the components' requestedmaximum sizesand also lets you align components.For further details, see<a href="box.html">How to Use BoxLayout</a>.</blockquote><h3><a name="card">CardLayout</a></h3><blockquote><p align=center><IMG SRC="../../figures/uiswing/layout/CardLayoutDemo.png" WIDTH="265" HEIGHT="105" ALT="A picture of a GUI that uses CardLayout"><IMG SRC="../../figures/uiswing/layout/CardLayoutDemo-2.png" WIDTH="265" HEIGHT="105" ALT="Another picture of the same layout"></p><p>The <code>CardLayout</code> class lets you implement an areathat contains different components at different times.A <code>CardLayout</code> is often controlled by a combo box,with the state of the combo box determiningwhich panel (group of components)the <code>CardLayout</code> displays.An alternative to using <code>CardLayout</code> is using a<a class="TutorialLink" target="_top" href="../components/tabbedpane.html">tabbed pane</a>, which provides similar functionalitybut with a pre-defined GUI.For further details, see<a href="card.html">How to Use CardLayout</a>.</blockquote><h3><a name="flow">FlowLayout</a></h3><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/FlowLayoutDemo.png" WIDTH="471" HEIGHT="70" ALIGN="BOTTOM" ALT="A picture of a GUI that uses FlowLayout"></center></p><code>FlowLayout</code> is the default layout manager forevery <code>JPanel</code>.It simply lays out componentsin a single row,starting a new row if its container isn't sufficiently wide.Both panels in CardLayoutDemo,shown <a href="#card">previously</a>,use <code>FlowLayout</code>.For further details, see<a href="flow.html">How to Use FlowLayout</a>.</blockquote><h3><a name="gridbag">GridBagLayout</a></h3><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/GridBagLayoutDemo.png" WIDTH="250" HEIGHT="164" ALIGN="BOTTOM" ALT="A picture of a GUI that uses GridBagLayout"></center></p><code>GridBagLayout</code> is a sophisticated,flexible layout manager.It aligns components by placing them within a grid of cells,allowing some components to span more than one cell.The rows in the grid can have different heights,and grid columns can have different widths.For further details, see<a href="gridbag.html">How to Use GridBagLayout</a>.</blockquote><h3><a name="grid">GridLayout</a></h3><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/GridLayoutDemo.png" WIDTH="318" HEIGHT="112" ALIGN="BOTTOM" ALT="A picture of a GUI that uses GridLayout"></center></p><code>GridLayout</code> simply makes a bunch of components equal in sizeand displays them in the requested number of rows and columns.For further details, see<a href="grid.html">How to Use GridLayout</a>.</blockquote><h3><a name="spring">SpringLayout</a></h3><blockquote><p><center><IMG SRC="../../figures/uiswing/layout/SpringBox.png" WIDTH="477" HEIGHT="72" ALIGN="BOTTOM" ALT="A picture of a GUI that uses SpringLayout"></center></p><p><center><IMG SRC="../../figures/uiswing/layout/SpringForm.png" WIDTH="192" HEIGHT="144" ALIGN="BOTTOM" ALT="Another GUI that uses SpringLayout"></center></p><code>SpringLayout</code> is a flexible layout managerdesigned for use by GUI builders.It lets you specify precise relationshipsbetween the edges of components under its control.For example, you might define thatthe left edge of one component is a certain distance(which can be dynamically calculated)from the right edge of a second component.For further details, see<a href="spring.html">How to Use SpringLayout</a>.        </blockquote>        <div class=NavBit>            <a target=_top href=index.html>&laquo; Previous</a>            &bull;            <a target=_top href=../TOC.html>Trail</a>            &bull;            <a target=_top href=using.html>Next &raquo;</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> Laying Out Components Within a Container        <br><b>Next page:</b> Using Layout Managers    </div>    </body></html> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -