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

📄 ch37.htm

📁 Java_by_Example,初级经典例子哦,珍藏版本
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<HTML><HEAD><TITLE>developer.com - Reference</TITLE><META NAME="Author" CONTENT="developer.com"><META NAME="Keywords" CONTENT="javascript, ActiveX, VRML, Push, channel,push channel, applet, directory, news, community, developer, internet,intranet, java, java applet, J++, javabeans, java products, tools, javatools, JDK, java development kit, java development environment, JIT,JavaPlan, enterprise tools, JVM, Java Virtual Machine, Java resources, API,browser, java documentation, CDF, Common Desktop Format, RDF, ResourceDescription Framework, Netcaster, Netcast, Castanet, meta-language, metadata,solaris, Solaris, SUN, CGI, Perl, Oracle, database, network, Netscape API,Apache, apache, SSL, mSQL, Netscape, Fasttrack, FastTrack,industry standard, ActiveX bridge, web, internet, site, sitedesign, microsoft, active server pages, asp, iis, nt, win95, 95, html, cgi,frontpage, business, corporate, vbscript, javascript, activex, isapi,database, access, sql, server, www, 3.0, 3.01, 3.02, 3.03, 3.04, 4.0,4.0b2, 4.01, 4.03, 4.04, connection, online, commerce, publisher,publishing, publish, webmaster, dynamic html, dhtml, windows 98, netscape,netscape software, shareware, magazines, jobs, japan, free, freeware, freestuff"><META NAME="description" CONTENT="Developer.com is the leading onlineservice for developers. It includes Gamelan, the official directory for Java, as wellas news, information, tutorials, and directories for other Internet technologiesincluding ActiveX, JavaScript, perl, VRML, Java Beans, push technologies, andother Internet and intranet technologies. Developer.com is also the home ofDeveloper Direct, the Professional Developer's Store, where developers canpurchase and download thousands of Web, authoring and other developmentproducts at some of today's lowest prices."><META NAME="distribution" CONTENT="global"><META NAME="resource-type" CONTENT="document"><META NAME="language" CONTENT="en"></HEAD><BODY BACKGROUND="/images/curve_r-wide.gif" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#DD0000" VLINK="#999999" ALINK="#FF0000"><TABLE><TR><TD VALIGN=TOP WIDTH=120><A HREF="/" ><IMG SRC="/images/masthead_r.gif" WIDTH="100" HEIGHT="78" BORDER="0"ALT="Developer.com Logo"></a></TD><TD><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCBAN.REF/DT=null"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCBAN.REF/DT=null" HEIGHT="60" WIDTH="468" ALT="Click here to support our advertisers"><BR><CENTER>Click here to support our advertisers</CENTER></a></TD></TR></TABLE><!--outer table--><TABLE><!--outer table--><TR><!--outer table--><TD VALIGN="TOP"><!--navbar info --><table><tr><td><A HREF="http://www.developerdirect.com/" ><IMG SRC="/images/button_s.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>SHOPPING</b></font></a></td></tr><tr><td><A HREF="/community/jobs/c_jobs.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>JOB BANK</B></font></a></td></tr><tr><td><A HREF="http://www.classifieds2000.com/cgi-cls/display.exe?Developer+computer+searchcomputercategories"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>CLASSIFIEDS</B></font></a></td></tr><tr><td><A HREF="/directories/directories.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>DIRECTORIES</B></font></a></td></tr><tr><td><A HREF="/reference/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>REFERENCE</B></font></a><br><a href="/reference/r_library.html"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">Online Library</a></font></td></tr><tr><td><A HREF="/classroom/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>LEARNING CENTER</B></font></a></td></tr><tr><td><A HREF="/journal/"><IMG SRC="/images/button_n.gif" width="15" height="11" BORDER="0"><B><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">JOURNAL</font></B></a></td></tr><tr><td><A HREF="/news/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>NEWS CENTRAL</b></font></a></td></tr><tr><td><A HREF="/downloads/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>DOWNLOADS</b></font></a></td></tr><tr><td><A HREF="/community/" ><IMG SRC="/images/button_c.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>COMMUNITY</B></font></a></td></tr><tr><td><A HREF="/calendar/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>CALENDAR</b></font></a></td></tr><tr><td><A HREF="/about/"><IMG SRC="/images/button_a.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>ABOUT US</b></a></font></td></tr></table><table><tr><td><form action="/subscribe/list.cgi" method=post ><img src="/images/rule.gif" width="100" height="2"><br><B><FONT FACE="Arial, Helvetica" SIZE="-1">Journal:</b></font><br><input name='email' value='your e-mail' size="11"><input type='hidden'  name='state' value='Subscribe'></td></tr><tr><td><input type='submit' value='Subscribe'><br><font size="-1">Get the weekly email highlights from the most popular journal for developers!<br><a href="http://www.developer.com/subscribe.html">Current issue</a><img src="/images/rule.gif" width="100" height="2"><input type='hidden' name='name' value='New Subscriber'></FORM></td></tr></table><!--/navbar--><font size="-1"><A HREF="http://www.developer.com">developer.com</a><BR><A HREF="http://www.developerdirect.com">developerdirect.com</a><BR><A HREF="http://www.htmlgoodies.com">htmlgoodies.com</a><BR><A HREF="http://www.javagoodies.com">javagoodies.com</a><br><A HREF="http://www.jars.com">jars.com</a><BR><a href="http://www.intranetjournal.com">intranetjournal.com</a><br><a href="http://www.javascripts.com">javascripts.com</a><br></font><!--outer table--></TD><!--outer table--><TD VALIGN="TOP"><BLOCKQUOTE><P><img src="/images/header_r.gif" width="440" height="50"><P><MAP NAME ="header_r2.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/author.html"      COORDS ="361,0,440,29"><AREA SHAPE ="RECT"      HREF ="/reference/basic.html"      COORDS ="254,0,360,29"><AREA SHAPE ="RECT"      HREF ="/reference/help.html"      COORDS ="183,0,251,29"><AREA SHAPE ="RECT"      HREF ="/reference/cool.html"      COORDS ="100,0,181,29"><AREA SHAPE ="RECT"      HREF ="/reference/mybook.html"      COORDS ="0,0,100,29"></MAP><MAP NAME ="header_r1.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/personalize.html"      COORDS ="339,0,439,29"></MAP><p><font face="Arial,Helvetica" size="-1" color="#006666"><A HREF="/reference/r_library.html"><B>All Categories</A> :</B><b><A HREF="/reference/r_java.html">Java</A></b></font><p><META><H1><FONT SIZE=6 COLOR=#Ff0000>Appendix&nbsp;A</FONT></H1><H1><FONT SIZE=6 COLOR=#Ff0000>Answers to Review Questions</FONT></H1><HR><P><CENTER><B><FONT SIZE=5><A NAME="CONTENTS">CONTENTS</A></FONT></B></CENTER><UL><LI><A HREF="#Chapter1">Chapter 1</A><LI><A HREF="#Chapter2">Chapter 2</A><LI><A HREF="#Chapter3">Chapter 3</A><LI><A HREF="#Chapter4">Chapter 4</A><LI><A HREF="#Chapter5">Chapter 5</A><LI><A HREF="#Chapter6">Chapter 6</A><LI><A HREF="#Chapter7">Chapter 7</A><LI><A HREF="#Chapter8">Chapter 8</A><LI><A HREF="#Chapter9">Chapter 9</A><LI><A HREF="#Chapter10">Chapter 10</A><LI><A HREF="#Chapter11">Chapter 11</A><LI><A HREF="#Chapter12">Chapter 12</A><LI><A HREF="#Chapter13">Chapter 13</A><LI><A HREF="#Chapter14">Chapter 14</A><LI><A HREF="#Chapter15">Chapter 15</A><LI><A HREF="#Chapter16">Chapter 16</A><LI><A HREF="#Chapter17">Chapter 17</A><LI><A HREF="#Chapter18">Chapter 18</A><LI><A HREF="#Chapter19">Chapter 19</A><LI><A HREF="#Chapter20">Chapter 20</A><LI><A HREF="#Chapter21">Chapter 21</A><LI><A HREF="#Chapter22">Chapter 22</A><LI><A HREF="#Chapter23">Chapter 23</A><LI><A HREF="#Chapter24">Chapter 24</A><LI><A HREF="#Chapter25">Chapter 25</A><LI><A HREF="#Chapter26">Chapter 26</A><LI><A HREF="#Chapter27">Chapter 27</A><LI><A HREF="#Chapter28">Chapter 28</A><LI><A HREF="#Chapter29">Chapter 29</A><LI><A HREF="#Chapter30">Chapter 30</A><LI><A HREF="#Chapter31">Chapter 31</A><LI><A HREF="#Chapter32">Chapter 32</A><LI><A HREF="#Chapter33">Chapter 33</A><LI><A HREF="#Chapter34">Chapter 34</A><LI><A HREF="#Chapter35">Chapter 35</A><LI><A HREF="#Chapter36">Chapter 36</A></UL><HR><H2><A NAME="Chapter1"><FONT SIZE=5 COLOR=#Ff0000>Chapter 1</FONT></A></H2><OL><LI>Probably the three most important reasons that Java is sosuitable for Internet applications are the language's robustness,simplicity, and, most importantly, its security features.<LI>A Java applet is a small program that is embedded in an HTMLdocument and is run when the document is loaded. A Java standaloneapplication doesn't need to be embedded in an HTML document andcan be run just like any other application.<LI>Java applets are compiled into byte-code files that can beexecuted by any computer that has a Java interpreter.<LI>Applets are handled in an HTML document similarly to elementslike images. The applet is referenced in the HTML document, whichcauses the HTML document to load and run the applet.<LI>Java is platform-independent so that it can run on any system.Java is also multithreaded, which means it can handle multipletasks concurrently and run fast.</OL><H2><A NAME="Chapter2"><FONT SIZE=5 COLOR=#Ff0000>Chapter 2</FONT></A></H2><OL><LI>Use the Appletviewer tool included with the JDK.<LI>The required attributes are <TT>code</TT>, <TT>width</TT>,and <TT>height</TT>.<LI>The <TT>codebase</TT> attribute specifies the location ofan applet's code (the .CLASS file). The given folder is relativeto the folder of the HTML document that contains the referenceto the applet.<LI>Other optional attributes include <TT>alt</TT>, <TT>align</TT>,<TT>name</TT>, <TT>hspace</TT>, and <TT>vspace</TT>.<LI>Applet parameters enable a user to configure an applet tofit his specific needs.<LI>You can provide alternate content for non-Java browsers. Youdo this by placing standard HTML script commands for the alternatecontent right before the ending <TT>&lt;/applet&gt;</TT> tag.</OL><H2><A NAME="Chapter3"><FONT SIZE=5 COLOR=#Ff0000>Chapter 3</FONT></A></H2><OL><LI>A local applet is located on your computer system.<LI>A remote applet is located on another computer system andmust be downloaded onto your computer before it can be run.<LI>The client is the computer that requests information (in thiscase, an applet) from another computer. The computer that suppliesthe information is the server.<LI>Once applets can flow both from and to a remote computer,the client/server relationship will become less important. Thisis because computers will keep switching from being a client anda server.<LI>The Java interpreter validates every applet before the appletis run. This prevents applets that have been modified (maybe byhaving a virus attached) from affecting the destination system.The validation process also ensures that an applet cannot crashthe system.</OL><H2><A NAME="Chapter4"><FONT SIZE=5 COLOR=#Ff0000>Chapter 4</FONT></A></H2><OL><LI>When you use top-down programming, you divide a program upsuch that the detail goes from general to specific as you workyour way down the program.<LI>Top-down programming enables you to separate the general tasksthat must be completed by a program from the details that implementthose tasks, making a program easier to understand and organize.<LI>OOP offers another organizational level to the programmer.Not only can the programmer divide tasks up into logical chunksin top-down, structured fashion, but he can also separate logicalelements of the program into objects.<LI>The two main elements of a class are data fields and the methodsthat operate on the data fields.<LI>A class is like a template or blueprint for an object. Anobject is an instance of the class.<LI>The three main OOP concepts are encapsulation, inheritance,and polymorphism.<LI>Encapsulation is the act of enclosing both the data and thefunctions that act on the data within the object. Inheritanceis the ability of a new object (a derived object) to inherit dataand functions from a base object. Polymorphism is the abilityof a derived object to implement a function of the base classin a different way.</OL><H2><A NAME="Chapter5"><FONT SIZE=5 COLOR=#Ff0000>Chapter 5</FONT></A></H2><OL><LI>A constant is a value that can't be changed during a program'sexecution. Constants have symbolic names like <TT>PI</TT> or <TT>NUMBEROFITEMS</TT>.<LI>A variable is a value that can be changed as much as neededduring a program's execution. Like constants, variables have symbolicnames. Examples of variable names are <TT>count</TT> and <TT>area_of_circle</TT>.<LI>Constants and variables replace hard-to-understand valueswith English-like names. Moreover, variables enable you to namea value that must change many times during program execution.<LI>Java's eight data types are <TT>byte</TT>, <TT>short</TT>,<TT>int</TT>, <TT>long</TT>, <TT>float</TT>, <TT>double</TT>,<TT>char</TT>, and <TT>boolean</TT>.<LI>Variable scope determines where in a program a variable canbe accessed. A variable goes into scope at the beginning of theprogram block in which the variable is declared and goes out ofscope at the end of the block.</OL><H2><A NAME="Chapter6"><FONT SIZE=5 COLOR=#Ff0000>Chapter 6</FONT></A></H2><OL><LI>Graphical text is text that must be drawn on the screen justlike other shapes such as circles and squares, rather than printedusing a built-in character set as is done under MS-DOS.<LI>In a proportional font, each letter takes up only the amountof space it needs, whereas every letter in a non-proportionalfont takes up exactly the same amount of space.<LI>Arguments are values that are sent to a method when the methodis called.<LI>The three arguments for the <TT>drawString()</TT> method are

⌨️ 快捷键说明

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