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

📄 ch39.htm

📁 Java_by_Example,初级经典例子哦,珍藏版本
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<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;C</FONT></H1><H1><FONT SIZE=6 COLOR=#Ff0000>IDEs and Tools</FONT></H1><P><I><B>by </B>David Medinets</I><HR><P><CENTER><B><FONT SIZE=5><A NAME="CONTENTS">CONTENTS</A></FONT></B></CENTER><UL><LI><A HREF="#IDEs">IDEs</A><UL><LI><A HREF="#Diva">Diva</A><LI><A HREF="#Java">Java+</A><LI><A HREF="#JavaMaker">JavaMaker</A></UL><LI><A HREF="#Tools">Tools</A><UL><LI><A HREF="#AppletGen">AppletGen</A><LI><A HREF="#VbToJava">VbToJava</A><LI><A HREF="#PortaFilter">PortaFilter</A></UL><LI><A HREF="#Summary">Summary</A></UL><HR><P>This book has shown you how to create simple Java programs. Whenyou start to create larger programs with multiple classes youwill need some tools to help you organize and compile your programmingprojects.<P>Fortunately there are IDEs, or Integrated Development Environments.An IDE is a program that lets you group a bunch of files intoa project and thereby increase programmer productivity. Even thoughthe Java language is still in its infancy the cutting-edge programmersof the world already have started to create the tools needed tobring Java into the world of corporate America and mainstreamprogramming.<P>In addition to the basic IDE, a number of tools are becoming availableto help you with programming tasks. For example, there is a programavailable that will let you design a dialog box in Visual Basicand have it automatically converting into Java using the AWT.<P>This appendix will take a quick look at the IDEs and tools thatare available for downloading from the World Wide Web. Pleaseremember that the state-of-the-art in Java development is changingso rapidly that the any details presented here are almost guaranteedto be obsolete when you read them. Therefore, only one IDE willbe discussed in depth-to give you an idea what you can expectin an IDE.<P>There are two good ways to find more information about IDEs orJava tools:<UL><LI>Internet Search Engines&nbsp;&nbsp;These Web sites let youspecify search criteria. Then, the engine will look at its databaseand display a list of  Web pages that contain the text you specified.For example, you could search for &quot;JAVA&quot;, &quot;IDE&quot;,and &quot;Win95&quot; in order to find Java IDEs that run underthe Windows 95 operating system. The JAVA.htm file on the CD-ROMhas links to some good search engines. If you are not alreadyfamiliar with them, take the time to use them-they are a greatresource.<LI>Java UseNet Newsgroup&nbsp;&nbsp;This newsgroup (comp.lang.java)is where a lot of experienced Java developers hang out, help newprogrammers, and discuss the future. You will also see a lot ofnew programs being announced here. It should take no more than10 minutes a day to monitor the newsgroup.</UL><H2><A NAME="IDEs"><FONT SIZE=5 COLOR=#Ff0000>IDEs</FONT></A></H2><P>I believe that the greatest advantage of an IDE is that it actsto isolate you from the command-line of a compiler. When a sourcefile needs to be compiled, frequently you will only need to highlightthe file and click a compile icon. The Java compiler will be calledas a subprocess and all compiler messages will be captured intoa window. Typically, you need only click an error message in orderto see the offending source code.<P>You will also see gains in both productivity and organizationbecause you will no longer need to type in the file name eachtime a compilation is needed. This will help organization-youwill no longer be reluctant to give your classes (and hence, thesource files) descriptive names because of the amount of typingneeded for each compilation.<P>All IDEs work-more or less-in the same manner:<OL><LI>The IDE creates a project file. It is usually a good ideato isolate each project to its own directory. However, this isnot a hard-and-fast rule. I frequently place small projects orexample programs in the same directory.<LI>The IDE changes project settings and preferences to reflectthe requirements of the current project. For example, you mightwant all of your .class files to be placed into the same directorywhen the compiler creates them. Another example might be settingthe command-line options for the compiler.<LI>The IDE enables you to add source files to the project. Eachproject file holds a list of which .java files are used by theproject. Some IDEs will also let you associate .htm or .html fileswith a project. This makes working with applets easier. When creatingnew source files, most IDEs will ask if you want to add the newfile to the project.<LI>A built-in editor allows you to change the source code asneeded.<LI>You can compile code by selecting a menu option or icon. Messagesfrom the compiler are captured to a window.<LI>You can run Appletviewer, Web browser, or Interpreter by selectinga menu option or icon. This allows you to test your code.</OL><P><P><CENTER><TABLE BORDER=1 WIDTH=80%><TR VALIGN=TOP><TD><B>NOTE</B></TD></TR><TR VALIGN=TOP><TD><BLOCKQUOTE>In order for any IDE to compile your Java source code, Sun's Java Development Kit (JDK) must already be loaded. It will help if you place the BIN directory of the JDK into your path. This can usually be accomplished by added the following line to your AUTOEXEC.BAT file:</BLOCKQUOTE><BLOCKQUOTE><TT>set PATH=%PATH%;C:\JDK\BIN;</TT></BLOCKQUOTE><BLOCKQUOTE>Of course, you will need to replace the C:\JDK with the name of the directory in which you installed the JDK.</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><P>Let's take a close look at the Diva IDE. Diva will be used forthe examples in this chapter for several reasons. The most importantbeing that you can download it from the Net. The file JAVA.htmon the CD has a link that you can use to download Diva. Once youhave created a project in Diva, you will probably be able to adaptto any Java IDE with ease.<H3><A NAME="Diva">Diva</A></H3><P>It is important to note that the version of Diva that is describedhere is an alpha version. The version that you download and usemight look different.<P>Before you can follow along with the examples shown below, youwill need to install both Sun's Java Developement Kit (JDK) andDiva. I'll assume that you already know how to install the JDK.Diva is installed by uncompressing the DIVA.ZIP. I'll use C:\DIVAas the base directory for the following examples, but you canuse any directory you'd like.<H4>An Example</H4><P>In this example you will use Diva to create an application thatdisplays a window-called a frame in Java-that responds to theuser's clicking the Close button. Follow these steps:<OL><LI>Start Diva by double-clicking the DIVA.EXE file in the C:\DIVAdirectory.<LI>Select the File, Create New Project menu option to displaythe Create New Javaside Project dialog box, as shown in FigureC.1<BR><A HREF="fc-1.gif"><B>Figure C.1 :</B> <I>The Create New Project dialog box.</I></A><LI>Enter myFrame into the file name field and click the Savebutton to close the dialog box. The Diva screen should now looklike Figure C.2<BR><A HREF="fc-2.gif"><B>Figure C.2</B> : <I>The Diva IDE</I>.</A><LI>Select File, New File to display the New dialog box. Thenselect Java in the choice list and click the OK button to closethe dialog box. Diva will create another window to hold the contentsof the new file as shown in Figure C.3. I added the text &quot;Entertext here&quot; to the new file so that you could easily see whichwindow was added.<BR><A HREF="fc-3.gif"><B>Figure C.3</B> : <I>An almost empty Java File in the Diva IDE</I>.</A><LI>Enter Listing C.1 into the editor window.<P><P><CENTER><TABLE BORDER=1 WIDTH=80%><TR VALIGN=TOP><TD><B>NOTE</B></TD></TR><TR VALIGN=TOP><TD><BLOCKQUOTE>Diva was previously named Javaside. Some of the messages and dialog boxes in this alpha version still show the old name.</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><HR><BLOCKQUOTE><B>Listing C.1&nbsp;&nbsp;MYFRAME.JAVA: A Program To Display aSimple Frame.<BR></B></BLOCKQUOTE><BLOCKQUOTE><PRE>import java.awt.*;class myFrame extends Frame {				public myFrame(String title) {		super(title);		resize(200, 350);

⌨️ 快捷键说明

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