- 1、本文档共42页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
* Locating Resource Using the URL Class The .URL class can be used to identify files (image, audio, text, etc.) on the Internet. In general, a URL (Uniform Resource Locator) is a pointer to a “resource” on the World Wide Web on a local machine or a remote host. A resource can be something as simple as a file or a directory. An URL for a file can also be accessed by class code in a way that is independent of the location of the file as long as the file is located in the class directory. Recall that the class directory is where the class (i.e., the .class file) is stored. For example, all the classes in this book are stored in c:\book. So the class directory is c:\book. * Creating a URL from a Class Reference As discussed in §9.11.5, “The getClass Method,” when a class is loaded, the JVM creates a meta-object for the class, which can be obtained using java.lang.Class metaObject = this.getClass(); The Class class provides access to useful information about the class, such as the data fields, constructors, and methods. It also contains the getResource(filename) method, which can be used to obtain the URL of a given file name in the class directory. To obtain the URL of a file in the class directory, use URL url = metaObject.getResource(filename); For example, suppose the class directory is c:\book, the following statements create a URL for c:\book\image\us.gif. Class metaObject = this.getClass(); URL url = metaObject.getResource(image/us.gif); You can now create an ImageIcon using ImageIcon imageIcon = new ImageIcon(url); * Displaying Image Write a program that displays an image from /image/us.gif in the class directory on a panel. DisplayImageWithURL Run * Creating AudioClip from an Audio File To play an audio file in an applet, first create an audio clip object for the audio file. The audio clip is created once and can be played repeatedly without reloading the file. To create an audio clip, use the static method newAudioClip() in the java.applet.Applet class: ?
您可能关注的文档
- 2012-2013学年(下)概论期末小论文考试注意事项.ppt
- 2016研究生受体第一次3学时.ppt
- Android进阶课程实验报告-家庭电话簿应用3.doc
- Android进阶课程实验报告-家庭电话簿应用5.doc
- 2016研究生受体第二次3学时.ppt
- Android移动应用开发课程报告.docx
- Android进阶课程实验报告-家庭电话簿应用2.doc
- Android移动应用开发课程报告1.docx
- Android移动应用开发课程报告3.docx
- C++ How to Program 习题答案.pdf
- 第四单元能力提升卷-2022-2023学年八年级下册语文课时分层训练原卷版.docx
- 浙江省宁波市2023年初中学业水平模拟考试英语试卷(一)(考试A4版).docx
- 夯实基础60题必刷题专训(第八九十章)(人教版).docx
- 第四单元 走向和平发展的世界讲义江西省中考一轮复习.docx
- 余数和除数的关系(教学设计)-2023-2024学年二年级下册数学人教版.docx
- 专题06光学真题训练.docx
- 贵州省普通高中课程安排指导表.pdf
- 第二单元世界舞台上的中国-2023-2024学年九年级道德与法治下册单元精讲速记巧练.docx
- 24.7向量的线性运算(第2课时)(作业)(原卷版).docx
- 重组卷05-冲刺2022年中考语文精选真题重组卷(原卷版).docx
文档评论(0)