




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0外文原文Asallreadersknow,HTMLisatthefoundationoftheWeb.Throughthemechanismofhyperlinks,HTMLenablestexttobeorganizedinnonlinearwayssomethingthatisnotpossiblewiththetraditional,top-downrepresentation.Becauseofthepowerofhyperlinks,HTMLisbeingusedinincreasingnumbersofnon-Web-relatedapplications,too.Forexample,todaymanyHelpfilesuseHTMLtorepresenttheirinformation.BecauseoftheimportanceofHTMLtothemoderncomputingenvironment,itisnotuncommontoencounterasituationinwhichtherenderingofHTMLiseitherrequiredordesired.Inthepast,suchataskwaschallengingbecauseoftherichnessoftheHTMLcommandsetandtheneedtoprocesshyperlinks.Fortunately,Javasimplifiesthistask,althoughnotallJavaprogrammersareawareofit.SupportforHTMLisincludedintheSwingframework.Thissupportincludestheabilitytodisplay(render)HTMLandhandlehyperlinkeventnotifications.HTMLcanberenderedbytheJEditorPaneclass.HyperlinkeventsaremanagedviatheHyperlinkEventclassandTheHyperlinkListenerinterface.Javasbuilt-insupportforHTMLisacapabilitythatisoftenoverlooked.ThischapterbeginsbydescribinghowtorenderHTMLbyusingJEditorPaneandhowtohandlehyperlinkevents.ItthendemonstratesthesecapabilitiesbycreatingasimpleWebbrowser.Ofcourse,therenderingofHTMLisnotlimitedtobrowsers.YoucanusethetechniquesdescribedherewheneveryouneedtodisplayandprocessHTML.SwingsJEditorPaneclassmakestherenderingofHTMLeasy.SimplyinstantiateaJEditorPaneandthensetitscontenttypetotext/html.WhendisplayingHTML,youwillalsoneedtodisableediting.Thefollowingsequenceshowstheproceduretofollow:JEditorPanehtmlViewer=newJEditorPane();htmlViewer.setContentType(text/html);htmlViewer.setEditable(false);AfterinstantiatingaJEditorPaneinstancecalledhtmlViewer,setContentType()iscalledtocausehtmlViewertorenderitscontentasHTML.CallingsetEditable()withaparameteroffalsepreventsthecontentsoftheeditorpanefrombeingchanged.ItalsoallowsHTMLtagstoberenderedratherthandisplayedastags.ThesestepsareallthatisrequiredtoprepareaJEditorPaneforrenderingHTMLandareaperfectexampleoftheartofJava!Anotherbonuswiththiseditionisthefreemultimediaseminarthatyoucandownloadfromwww.MindV.ThisistheThinkinginCseminarthatgivesyouanintroductiontotheCsyntax,operators,andfunctionsthatJavasyntaxisbasedupon.InpreviouseditionsofthebookthiswasintheFoundationsforJavaCDthatwaspackagedwiththebook,butnowtheseminarmaybefreelydownloaded.IoriginallycommissionedChuckAllisontocreateThinkinginCasastandaloneproduct,butdecidedtoincludeitwiththe2ndeditionofThinkinginC+and2ndand3rdeditionsofThinkinginJavabecauseoftheconsistentexperienceofhavingpeoplecometo1seminarswithoutanadequatebackgroundinbasicCsyntax.Thethinkingapparentlygoes“ImasmartprogrammerandIdontwanttolearnC,butratherC+orJava,soIlljustskipCandgodirectlytoC+/Java.”Afterarrivingattheseminar,itslowlydawnsonfolksthattheprerequisiteofunderstandingCsyntaxisthereforaverygoodreason.Technologieshavechanged,anditmademoresensetoreworkThinkinginCasadownloadableFlashpresentationratherthanincludingitasaCD.Byprovidingthisseminaronline,Icanensurethateveryonecanbeginwithadequatepreparation.TheThinkinginCseminaralsoallowsthebooktoappealtoawideraudience.EventhoughtheOperatorsandControllingExecutionchaptersdocoverthefundamentalpartsofJavathatcomefromC,theonlineseminarisagentlerintroduction,andassumesevenlessaboutthestudentsprogrammingbackgroundthandoesthebook.Ifascriptinglanguagecansolve80percentoftheclient-sideprogrammingproblems,whatabouttheother20percentthe“reallyhardstuff?”ThemostpopularsolutiontodayisJava.Notonlyisitapowerfulprogramminglanguagebuilttobesecure,cross-platform,andinternational,butJavaisbeingcontinuallyextendedtoprovidelanguagefeaturesandlibrariesthatelegantlyhandleproblemsthataredifficultintraditionalprogramminglanguages,suchasmultithreading,databaseaccess,networkprogramming,anddistributedcomputing.Javaallowsclient-sideprogrammingviatheapplet.Anappletisamini-programthatwillrunonlyunderaWebbrowser.TheappletisdownloadedautomaticallyaspartofaWebpage(justas,forexample,agraphicisautomaticallydownloaded).Whentheappletisactivateditexecutesaprogram.Thisispartofitsbeautyitprovidesyouwithawaytoautomaticallydistributetheclientsoftwarefromtheserveratthetimetheuserneedstheclientsoftware,andnosooner.Theusergetsthelatestversionoftheclientsoftwarewithoutfailandwithoutdifficultreinstallation.BecauseofthewayJavaisdesigned,theprogrammerneedstocreateonlyasingleprogram,andthatprogramautomaticallyworkswithallcomputersthathavebrowserswithbuilt-inJavainterpreters.(Thissafelyincludesthevastmajorityofmachines.)SinceJavaisafull-fledgedprogramminglanguage,youcandoasmuchworkaspossibleontheclientbeforeandaftermakingrequestsoftheserver.Forexample,youwontneedtosendarequestformacrosstheInternettodiscoverthatyouvegottenadateorsomeotherparameterwrong,andyourclientcomputercanquicklydotheworkofplottingdatainsteadofwaitingfortheservertomakeaplotandshipagraphicimagebacktoyou.Notonlydoyougettheimmediatewinofspeedandresponsiveness,butthegeneralnetworktrafficandloadonserverscanbereduced,preventingtheentireInternetfromslowingdown.OneadvantageaJavaapplethasoverascriptedprogramisthatitsincompiledform,sothesourcecodeisntavailabletotheclient.Ontheotherhand,aJavaappletcanbedecompiledwithouttoomuchtrouble,buthidingyourcodeisoftennotanimportantissue.2Twootherfactorscanbeimportant.Asyouwillseelaterinthisbook,acompiledJavaappletcancomprisemanymodulesandtakemultipleserver“hits”(accesses)todownload.(InJava1.1andhigherthisisminimizedbyJavaarchives,calledJARfiles,thatallowalltherequiredmodulestobepackagedtogetherandcompressedforasingledownload.)AscriptedprogramwilljustbeintegratedintotheWebpageaspartofitstext(andwillgenerallybesmallerandreduceserverhits).ThiscouldbeimportanttotheresponsivenessofyourWebsite.Anotherfactoristheall-importantlearningcurve.Regardlessofwhatyouveheard,Javaisnotatriviallanguagetolearn.IfyoureaVisualBasicprogrammer,movingtoVBScriptwillbeyourfastestsolution,andsinceitwillprobablysolvemosttypicalclient/serverproblemsyoumightbehardpressedtojustifylearningJava.IfyoureexperiencedwithascriptinglanguageyouwillcertainlybenefitfromlookingatJavaScriptorVBScriptbeforecommittingtoJava,sincetheymightfityourneedshandilyandyoullbemoreproductivesooner.torunitsappletswithi3中文翻译由于所有的读者都知道,HTML是在Web的基础。通过超链接的机制,允许的HTML文本,将组织在非线性的方式,东西是不可能与传统的,自上而下的代表性。因为超链接的力量,HTML是被增加的非Web相关的数字用应用了。例如,现在很多的帮助文件使用HTML来表示他们的信息。因为HTML的现代计算环境的重要性,这是不寻常遇到的情况是,要么需要或期望的HTML的渲染。在过去,这样的任务是因为HTML令集的丰富性和挑战性需要处理的超链接。幸运的是,Java的简化了这个任务,虽然不是所有的Java程序员都知道这一点。支持HTML包含在Swing框架。这种支持包括能力显示(渲染)HTML和处理超链接事件的通知。HTML可以呈现由theJEditorPane类。超链接事件通过theHyperlinkEvent类和管理theHyperlinkListener接口。Java的内置支持HTML是一种能力,那就是往往被忽视。本章首先描述如何呈现HTML由usingJEditorPane以及如何处理超链接事件。它通过创建一个简单的Web然后演示了这些功能浏览器。当然,HTML的呈现不限于浏览器。您可以使用技巧这里描述的,当您需要显示和处理的HTMLSwingsJEditorPane类使得HTML的渲染容易。简单地实例化一个JEditorPane中,然后设置其内容类型为“text/html的”。当显示的HTML,你还需要禁用编辑。下面的顺序显示遵循的程序:JEditorPane中htmlViewer=新的JEditorPane();htmlViewer.setContentType(“text/html的”);htmlViewer.setEditable(假);实例aJEditorPane例如calledhtmlViewer,的setContentType(后)被称为到causehtmlViewer呈现其作为HTML内容。CallingsetEditable(),其参数假防止被更改编辑器窗格中的内容。它还允许HTML标签呈现,而不是显示为标记。这些步骤所需要的所有准备aJEditorPane渲染HTML和是Java的艺术的一个很好的例子!因为有市民前来研讨会在没有基本的C语法足够的背景一致的体验,在Java中的思考。这一思想显然是去“我是一个聪明的程序员,我不想学C,而C+或Java的,所以我就跳过C和直接进入到C+/Java的。”抵达研讨会后,慢慢地洒在人们的理解C语法的前提是有一个很好的理由。技术已经改变了,而且更有意义返工C语言思考作为一个可下载的Flash演示文4稿,而不是把它作为一个光盘。通过网上提供这个研讨会,我可以保证每个人都可以有足够的准备开始。C语言研讨会的思考也让这本书以吸引更广泛的受众。尽管运营商和控制执行的章节做涵盖了Java的是来自C中的基本组成部分,网上研讨会是一个温和的介绍,并假定甚至少谈学生的编程背景并不比书。在网上,我可以保证每个人都可以有足够的准备开始。C语言研讨会的思考也让这本书以吸引更广泛的受众。尽管运营商和控制执行的章节做涵盖了Java的是来自C中的基本组成部分,网上研讨会是一个温和的介绍,并假定甚至少谈学生的编程背景并不比书。如果说一种脚本编制语言能解决80的客户端程序设计问题,那么剩下的20又该怎么办呢?它们属于一些高难度的问题吗?目前最流行的方案就是Java。它不仅是一种功能强大、高度安全、可以跨平台使用以及国际通用的程序设计语言,也是一种具有旺盛生命力的语言。对Java的扩展是不断进行的,提供的语言特性和库能够很好地解决传统语言不能解决的问题,比如多线程操作、数据库访问、连网程序设计以及分布式计算等等。Java通过“程序片”(Applet)巧妙地解决了客户端编程的问题。程序片(或“小应用程序”)是一种非常小的程序,只能在Web浏览器中运行。作为Web页的一部分,程序片代码会自动下载回来(这和网页中的图片差不多)。激活程序片后,它
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030中国当归内酯市场运行态势与投资风险预测报告
- 三只小猪锯木头课件
- 小儿退热药课件
- 面试技巧:高级面试题目及答案解析
- 年产20万套数字智能道闸系统建设项目可行性研究报告模板-立项备案
- 大学生辅导员期末评语
- 大学生村官上半年述职报告
- 大学生市场调查实习报告
- 期货从业资格之《期货法律法规》能力检测完整答案详解
- 职业规划必 备:升学面试题库攻略分享
- 2025年高压电工新版试题(附答案)
- 2024版安全技术咨询服务具体协议模板版B版
- 董事长的权利、职责、义务(5篇)
- K31作业现场安全隐患排除(K3)
- 港口基础设施监测技术
- 回顾长征路课件
- 为什么你的学生不思考?主题班会分享
- 医疗废物交接登记表(诊所、医务室、卫生所等)
- 气雾培技术行业市场突围建议书
- 2025届云南省施甸县第一中学物理高一下期末学业水平测试试题含解析
- python程序设计-说课
评论
0/150
提交评论