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

📄 compile.html

📁 jsf、swing的官方指南
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html>    <head>        <title>Compiling and Running Swing Programs (The Java&trade; Tutorials &gt;             Creating a GUI with JFC/Swing &gt; Getting Started with Swing)</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> Getting Started with Swing    </div>    <div id=LeftBar class=LeftBar_shown>        <div id=Contents>            <div class="linkLESSON"><a href="index.html">Getting Started with Swing</a></div><div class="linkAHEAD"><a href="about.html">About the JFC and Swing</a></div><div class="nolinkAHEAD">Compiling and Running Swing Programs</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>Getting Started with Swing</a>            </span>            <div class=NavBit>                <a target=_top href=about.html>&laquo;&nbsp;Previous</a>&nbsp;&bull;&nbsp;<a target=_top href=../TOC.html>Trail</a>&nbsp;&bull;&nbsp;<a target=_top href=../learn/index.html>Next&nbsp;&raquo;</a>            </div>            <div id=PageTitle>Compiling and Running Swing Programs</div>            <blockquote>This section explains how to compile and run a Swing application. The compilation instructions work for all Swing programs &#151; applets, as well as applications. Here are the steps you need to follow:<UL><LI>Install the latest release of the Java SE platform, if you haven'talready done so. <LI>Create a program that uses Swing components.<LI>Compile the program.<LI>Run the program.</UL><H3>Install the Latest Release of the Java SE Platform</H3><blockquote>You can download the latest release of the JDK for free from<A HREF="http://java.sun.com/javase/downloads">http://java.sun.com/javase/downloads</A>. </blockquote><H3>Create a Program That Uses Swing Components</H3><blockquote>You can use a simple program we provide, called HelloWorldSwing, that brings up the GUI shown in the figure below. The program is in a single file, <a class="SourceLink" target="_blank" href="../learn/examples/HelloWorldSwing.java"><code>HelloWorldSwing.java</code></a>. When you save this file, you must match the spelling and capitalization of its name exactly. <p><center><IMG SRC="../../figures/uiswing/learn/1helloworldswing.gif" WIDTH="210" HEIGHT="49" ALIGN="BOTTOM" ALT=""></center></p> </blockquote><H3>Compile the Program</H3><blockquote>Your next step is to compile the program. Here's an example of compiling <a class="SourceLink" target="_blank" href="examples/HelloWorldSwing.java"><code>HelloWorldSwing.java</code></a>: <blockquote><pre>javac HelloWorldSwing.java</pre></blockquote>If you can't compile, make sure you're using the compiler in arecent release of the Java platform. Once you've updated your JDK,you should be able to use the programs in this trail without changes.Another common mistake is installing the Java Runtime Environment (JRE)and not the full Java Development Kit (JDK) needed to compilethese programs. Refer to the <a class="TutorialLink" target="_top" href="../../getStarted/index.html">Getting Started</a> trail to help you solve any compiling problems you encounter.Another installation troubleshooting guide for the Java SE platformis available online under the "Sun Resources" tab at<A HREF="http://java.sun.com/javase/index.jsp/">http://java.sun.com/javase/index.jsp/</A>.</blockquote><H3>Run the Program</H3><blockquote>After you compile the program successfully, you can run it.Assuming that your program uses a standard look and feel &#151;such as the Java, Windows, or GTK+ look and feel &#151;you can use the interpreter to run the program without adding anythingto your class path. For example: <blockquote><pre>java HelloWorldSwing</pre></blockquote>For programs that use a nonstandard look and feel or any other nonstandard code package, you must make sure that the necessary classes are in the class path. For example: <DL><DT><B>Solaris/Linux</B></DT>  <DD>java -classpath.:/home/me/lnfdir/newlnf.jar HelloWorldSwing<P><DT><B>Microsoft Windows</B></DT>  <DD>java -classpath .;C:\java\lnfdir\newlnf.jar HelloWorldSwing</DL>Alternatively, you can launch your program from a Web browser using Java Web Start.</blockquote><a name="jws"><H3>Running Programs Using Java Web Start</H3></a><blockquote>Java Web Start is a technology that simplifies the distribution of applications. With a click on a Web page link, you can launch full-featured applications without a complicated download and installation process. The first time you launch an application, Java Web Start automatically downloads all necessary files. It then caches them on your computer so the application can be quickly relaunched from a desktop shortcut or from a Web browser. Java Web Start checks for updates each time you run a remote application and downloads any updated files automatically.<P>In 1.4.1 and later releases of the Java platform, Java Web Start isshipped as part of the platform. So, if you have version 1.4.1 or higher,you already have Java Web Start installed.When you install a version of the Java platform with Java Web Start,on most platforms you'll see a Java Web Start shortcut on your desktop.<p><center><IMG SRC="../../figures/uiswing/start/1jwsshortcut.gif" WIDTH="58" HEIGHT="68" ALIGN="BOTTOM" ALT=""></center></p>To test whether your browser can launch an application using Java Web Start,<a href="http://java.sun.com/docs/books/tutorialJWS/uiswing/start/examples/HelloJWS.jnlp">click this link</a>. <p>You should see a Java Web Start splash screen, such as the following.<p><center><IMG SRC="../../figures/uiswing/start/JWSsplash.gif" WIDTH="400" HEIGHT="300" ALIGN="BOTTOM" ALT=""></center></p>The application is then downloaded, and you should see this:<p><center><IMG SRC="../../figures/uiswing/start/hellojws.gif" WIDTH="303" HEIGHT="97" ALIGN="BOTTOM" ALT=""></center></p>If you're unable to launch this application, you should check <a class="TutorialLink" target="_top" href="../../information/javawebstart.html">Installing and Using Java Web Start</a>.</blockquote>        </blockquote>        <div class=NavBit>            <a target=_top href=about.html>&laquo; Previous</a>            &bull;            <a target=_top href=../TOC.html>Trail</a>            &bull;            <a target=_top href=../learn/index.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> About the JFC and Swing        <br><b>Next page:</b> Learning Swing by Example    </div>    </body></html> 

⌨️ 快捷键说明

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