📄 index.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html> <head> <title>Using Swing Components: Examples (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)</title><style type="text/css"> .FigureCaption { margin-left: 1in; margin-right: 1in; font-family: sans-serif; font-size: smaller; text-align: justify; } #TopBar_bl { background: url(../../../images/java_bar_bl.gif) 0 100% no-repeat; width: 100%; height: 60px; } #TopBar_br { background: url(../../../images/java_bar_br.gif) 100% 100% no-repeat; width: 100%; height: 60px; } #TopBar_tl { background: url(../../../images/java_bar_tl.gif) 0 0 no-repeat; width: 100%; height: 60px; } #TopBar_tr { background: url(../../../images/java_bar_tr.gif) 100% 0 no-repeat; width: 100%; height: 60px; } #TopBar { background: #35556B url(../../../images/java_bar.gif); margin: 10px 10px 0 10px; height:60px; min-width:700px; color: white; font-family: sans-serif; font-weight: bold; } @media print { #BreadCrumbs, #Download { display: none; } } #TopBar_right { line-height: 14px; float: right; padding-top: 2px; padding-right: 30px; text-align: center; } @media print { #TopBar_right { display: none; } } #TopBar_right a { font-size: 12px; margin: 3px; padding: 0; } #TopBar a:visited, #TopBar a:link { color: white; text-decoration: none; } #TopBar a:hover, #TopBar a:active { background-color: white; color: #35556B; } #BreadCrumbs { padding: 4px 5px 0.5em 0; font-family: sans-serif; float: right; } #BreadCrumbs a { color: blue; } #BreadCrumbs a:visited, #BreadCrumbs a:link { text-decoration: none; } #BreadCrumbs a:hover, #BreadCrumbs a:active { text-decoration: underline; } #PageTitle { margin: 0 5px 0.5em 0; color: #E76F00; font-family: sans-serif; font-weight: bold; font-size: 20px; } .LeftBar_shown { width: 13em; float: left; margin-left: 10px; margin-top: 4px; margin-bottom: 2em; } @media print { .LeftBar_shown { display: none; } } .LeftBar_hidden { display: none; } #Footer { padding-top: 10px; padding-left: 10px; margin-right: 10px; } .NavBit { padding: 4px 5px 0.5em 0; font-family: sans-serif; } @media print { .NavBit { display: none; } } #TagNotes { text-align: right; font-size: smaller; font-family: sans-serif; } @media print { #TagNotes a:visited, #TagNotes a:link { color: #35556B; text-decoration: none; } } #Contents a, .NavBit a, #TagNotes a { color: blue } #TagNotes a:visited, #TagNotes a:link, #Contents a:visited, #Contents a:link, .NavBit a:visited, .NavBit a:link { text-decoration: none; } #TagNotes a:hover, #TagNotes a:active, #Contents a:hover, #Contents a:active, .NavBit a:hover, .NavBit a:active { text-decoration: underline; } #Contents { float: left; font-family: sans-serif; } @media print { #Contents { display: none; } } @media screen { div.PrintHeaders { display: none; } } .linkLESSON, .nolinkLESSON { margin-left: 0.5em; text-indent: -0.5em } .linkAHEAD, .nolinkAHEAD, .linkQUESTIONS, .nolinkQUESTIONS { margin-left: 1.5em; text-indent: -0.5em } .linkBHEAD, .nolinkBHEAD { margin-left: 2.5em; text-indent: -0.5em } .linkCHEAD, .nolinkCHEAD { margin-left: 3.5em; text-indent: -0.5em } .nolinkLESSON, .nolinkAHEAD, .nolinkBHEAD, .nolinkCHEAD, .nolinkQUESTIONS { font-weight: bold; color: #E76F00; } .MainFlow_indented { margin-right: 10px; margin-left: 15em; margin-bottom: 2em; } .MainFlow_wide { margin-right: 10px; margin-left: 10px; margin-bottom: 2em; } @media print { .MainFlow_indented, .MainFlow_wide { padding-top: 0; margin-top: 10px; margin-right: 10px; margin-left: 0; } } h3, h4, h5 { color: #E76F00; font-family: sans-serif; } #ToggleLeft { display: none; } /t</style><script type="text/javascript"> function leftBar() { var nameq = 'tutorial_showLeftBar=' var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookieString = cookies[i]; while (cookieString.charAt(0) == ' ') { cookieString = cookieString.substring(1, cookieString.length); } if (cookieString.indexOf(nameq) == 0) { cookieValue = cookieString.substring(nameq.length, cookieString.length); return cookieValue == 'yes'; } } return true; } function showLeft(b) { var contents = document.getElementById("LeftBar"); var main = document.getElementById("MainFlow"); var toggle = document.getElementById("ToggleLeft"); if (b) { contents.className = "LeftBar_shown"; main.className = "MainFlow_indented"; toggle.innerHTML = "Hide the TOC"; document.cookie = 'tutorial_showLeftBar=yes; path=/'; } else { contents.className = "LeftBar_hidden"; main.className = "MainFlow_wide"; toggle.innerHTML = "Show the TOC"; document.cookie = 'tutorial_showLeftBar=no; path=/'; } } 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> Using Swing Components </div> <div class=MainFlow_wide> <span id=BreadCrumbs> <a href=../../../index.html target=_top>Home Page</a> > <a href=../../index.html target=_top>Creating a GUI with JFC/Swing</a> > <a href=../index.html target=_top>Using Swing Components</a> </span> <div class=NavBit> <a target=_top href=../../learn/examples/index.html>« Previous</a> • <a target=_top href=../../TOC.html>Trail</a> • <a target=_top href=../../misc/examples/index.html>Next »</a> </div> <div id=PageTitle>Using Swing Components: Examples</div> <blockquote>The <a href=#table>table</a> that followslists every example in the Using Swing Components lesson,with links to required files and to where each example is discussed.The first column of the table has links to JNLP filesthat let you run the examples using Java<sup><font size=-2>TM</font></sup> Web Start.<p><blockquote><hr><strong>NOTE:</strong> Release 6.0 is required to run all applets and Java Web Start examples. Most examples will run on an earlierrelease but you must compile and run them locally.<hr></blockquote><p>To run an example using Java Web Start,click the <em>[Run]</em> link in the first column of the<a href="#table">table</a>.The first time you run an example,there will be a delaywhile Java Web Start downloads the JAR file containing the class files for this lesson's examples.Afterward, the examples should execute more quickly.If you have trouble using Java Web Start, see<a class="TutorialLink" target="_top" href="../../../information/javawebstart.html">Installing and Using Java Web Start</a>.</blockquote><h4>Compiling and Running the Examples Locally</h4><blockquote><blockquote><hr><strong>Note:</strong> Examples are applicationsunless noted otherwise.See <a class="TutorialLink" target="_top" href="../../../uiswing/start/index.html">Getting Started with Swing</a> for details about releases and instructions on compiling and running programs.<hr></blockquote>You can get the source, image, and other files requiredfor all these examples by downloading the<a class="OutsideLink" target="_blank" href="http://java.sun.com/docs/books/tutorial/information/download.html#egs">Tutorial Examples bundle</a>, which contains the files in the correct hierarchy.If you download an individual example,take care to have all the necessary files in the proper hierarchy when you compile and run it.For example, many examplesexpect their image filesto be in a directory named <code>images</code>that's in the same directory as the example's class files.Here's a typical setup:<p><center><IMG SRC="../../../figures/uiswing/components/ButtonDemoFiles.gif" WIDTH="407" HEIGHT="154" ALIGN="BOTTOM" ALT="Directory structure"></center></p><p>You can find out which files each example needsby consulting the following tableor by looking at the commentsat the beginning of each source file.</p></blockquote><a name="table"><h4>Table of Examples</h4></a><p><table border="1"><tr><td><strong>Example<td><strong>Source Files<br><em>(first file has the main method, except for examples that run only as applets)</em></td><td><strong>Image and Other Files</strong></td><td><strong>Where Described</td></tr><tr><td><a name="BorderDemo">BorderDemo <a href="http://java.sun.com/docs/books/tutorialJWS/uiswing/misc/examples/BorderDemo.jnlp"><em>[Run]</em></a><td> <a class="SourceLink" target="_blank" href="BorderDemo.java"><code>BorderDemo.java</code></a> </a></td><td><a href="images/wavy.gif"><code>wavy.gif</code></a></td><td><a href="../border.html"> How to Use Borders</a></td></tr><tr><td valign=top><a name="ButtonDemo">ButtonDemo <a href="http://java.sun.com/docs/books/tutorialJWS/uiswing/components/examples/ButtonDemo.jnlp"><em>[Run]</em></a><td valign=top>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -