在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → JavaFX 2.0 電子書 - Pro JavaFX 2

JavaFX 2.0 電子書 - Pro JavaFX 2

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:36.40M
  • 下载次数:9
  • 浏览次数:94
  • 发布时间:2021-03-09
  • 实例类别:一般编程问题
  • 发 布 人:好学IT男
  • 文件格式:.pdf
  • 所需积分:2
 

实例介绍

【实例简介】
最新JavaFx 2.0 電子書 In Pro JavaFX 2: A Definitive Guide to Rich Clients with Java Technology, Jim Weaver, Weiqi Gao, Stephen Chin, Dean Iverson, and Johan Vos show you how you can use the JavaFX platform to create rich-client Java applications. You'll see how JavaFX provides a powerful Java-based UI pl
Contents at a glance Foreword ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ About the authors ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ About the technical reviewer XVIl Acknowledgments,,,,,,,,算,算,,XiX Chapter 1: Getting a Jump Start in JavaFX ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Chapter2 Creating a User Interface in JavaFX,…,…,,,,…,,,,,,35 Chapter 3: Properties and Bindings.mm aaaaaa.93 Chapter 4: Building Dynamic UI Layouts in JavaFXaas g137 Chapter 5: Using the JavaFX UI Controls an 1■■■■■■■■■■■ ■■■■■ 183 Chapter 6: Collections and Concurrency mm ammmmmmmamn 231 Chapter 7: Creating Charts in JavaFXaaa u307 Chapter 8: Using the Media Classes m maat 335 Chapter 9: Accessing Web Services 391 Chapter 10: JavaFX Languages and Markup mmmmmmmm. 431 Appendix: The visage Language in Depth aaaaaa 477 Index… 609 CHAPTER 1 Getting a Jump Start in JavaFX Dont ask what the world needs. Ask what makes you come alive, and go do it. Because what the world needs is people who have come alive Howard Thurman At the annual JavaOne conference in May 2007, Sun Microsystems announced a new product family named JavaFX. Its stated purpose includes enabling the development and deployment of content-rich applications on consumer devices such as cell phones, televisions, in-dash car systems, and browsers Josh Marinacci, a software engineer at Sun, made the following statement very appropriately in a recent Java Posse interview: JavaFX is sort of a code word for reinventing client Java and fixing the sins of the past. " Josh was referring to the fact that Java Swing and Java 2D have lots of capability, but are also ver complex. JavaFX allows us to simply and elegantly express user interfaces(UIs)with a declarative programming style. It also leverages the full power of Java, because you can instantiate and use the millions of Java classes that exist today. Add features such as binding the Ui to properties in a model and change listeners that reduce the need for setter methods, and you have a combination that will help restore Java to the client side of the rIa equation In this chapter, we give you a jump start in developing JavaFX applications. After bringing you up to date on the brief history of JavaFX, we show you how to get the JavaFX software development kit(SDK We also explore some great JavaFX resources and walk you through the process of compiling and running JavaFX applications. In the process you'll learn a lot about the JavaFX API as we walk through application code together. First, however, we point out a related technology that is enabling the rise of rich-client Java JavaFX Can't Bring Rich-Client Java Back by Itself When Java was first introduced in 1995, the hope was that the Java Runtime Environment urE)would become the common client platform on which the ui portion of client-server applications could be deployed. Although the jre became ubiquitous on the server side of the equation, factors such as the browser wars of the late 1990s delayed the prospect of achieving a consistent JRE on client machines The result has been that web browser technologies such as HTML and JavaScript have stepped in to fill the gap, which we feel has proven suboptimal at best. The software development industry and the users we serve need to have the jre on all client machines so that we can break free from browser technologies and enable graphically rich, fast-performing applications Fortunately, the technology known as Java SE 6 Update 10 is solving that problem CHAPTER 1 GETTING A JUMP START IN JAVAFX Note What has come to be known as Java se 6 Update 10 has actually had several names. It started life as the Consumer JRE, and then Java se 6 Update n. then it became known as Java se 6 Update 10. As of this writing Java se 7 has been released but we just refer to this technology as Java Se 6 Update 10 Java se 6 Update 10 consists of several technologies that improve the user experience related to installing the JRE, and to deploying and running rich-client Java(and JavaFX) programs Java Kernel online installer-The jRE is now divided into small bundles. If the user's machine doesnt have the jre installed when a Java program is invoked, the online installer will ascertain which of the bundles are needed to run the program Those bundles will be installed first and the program will begin executing as soon as this takes place Java Auto-Updater: This provides a faster and more reliable process for updating the jre by using a patch-in-place mechanism Java Quick starter: After a cold boot of the system, portions of the jre are prefetched into memory. This enables a Java program to start more quickly Pack200 Format: Pack200 is a highly compressed format that enables Java libraries and resources, for example, to download more quickly than traditional jar files Java deployment Toolkit: This includes a simple javaScript interface with which to deploy Java applets and applications. The JavaScript library is located at a well known URL, and is engineered to make the right deployment decisions based on the detected re environment on the users machine Next Generation Java Plug-In: This Java plug-in is much more reliable and versatile than its predecessor. For example, you now have the ability to specify large heap sizes, and per-applet command-line arguments. Also, it has built-in Java Network Launching Protocol (NLP)support as well as improved Java/JavaScript communications Hardware Acceleration Support: In a media-rich environment, it is crucial to take advantage of the graphics capabilities on the underlying hardware For example Java se 6 Update 10 currently has a hardware accelerated graphics pipeline based on the Microsoft Direct3D API. This is a predecessor to the new Prism pipeline that JavaFX uses The net result is that we are now at a point in software development history when two technologies the process of being restored to Internet software development, and we want you to join us in ns hg o UavaFX and Java Se 6 Update 10) are working together to restore rich client Java. We feel that sanity is revolution But first, a brief history lesson about JavaFX A Brief History of JavaFX JavafX started life as the brainchild of chris Oliver when he worked for a company named SeeBeyond They had the need for richer user interfaces, so Chris created a language that he dubbed F3(Form 2 CHAPTER 1 GETTING A JUMP START IN JAVAFX Follows Function) for that purpose. In the article, Mind-Bendingly Cool Innovation"(cited in the Resources section at the end of this chapter) Chris is quoted as follows. When it comes to integrating people into business processes, you need graphical user interfaces for them to interact with, so there was a use case for graphics in the enterprise application space, and there was an interest at See Beyond in having richer user interfaces See Beyond was acquired by Sun, who subsequently changed the name of F3 to JavaFX, and announced it at JavaOne 2007. Chris joined Sun during the acquisition and continued to lead the development of JavaFX The first version of JavaFX Script was an interpreted language, and was considered a prototype of the compiled javaFX Script language that was to come later. Interpreted JavaFX Script was very robust, and there were two JavaFX books published in the latter part of 2007 based on that version. One was written in Japanese, and the other was written in English and published by apress avaFX Script: Dynamic Java Scripting for Rich Internet/Client-Side Applications, Apress, 2007) While developers were experimenting with JavaFX and providing feedback for improvement, the JavaFX Script compiler team at Sun was busy creating a compiled version of the language. This included a new set of runtime API libraries. The JavaFX Script compiler project reached a tipping point in early December 2007, which was commemorated in a blog post entitled"Congratulations to the JavaFX Script Compiler Team-The Elephant Is Through the Door. " That phrase came from the JavaFX Script compiler project leader Tom Ball in a blog post, which contained the following excerpt an elephant analogy came to me when I was recently grilled about exactly when the JavaFX Script compiler team will deliver our first milestone release " I can't give you an accurate date, I said. It's like pushing an elephant through a door; until a critical mass makes it past the threshold you just don't know when you'll be finished. Once you pass that threshold, though, the rest happens quickly and in a manner that can be more accurately predicted A screenshot of the silly, compiled JavaFX application written by one of the authors, Jim Weaver, for that post is shown in Figure 1-1, demonstrating that the project had in fact reached the critical mass to Which Tom Ball referred 鸟 The Elephant is Through the Door回网 View Help Grey Pink Figure 1-1. Screenshot for the "Elephant Is Through the door" program CHAPTER 1 GETTING A JUMP START IN JAVAFX Much progress continued to be made on JavaFX in 2008 The NetBeans JavaFX plug-in became available for the compiled version in March Many of the JavaFX runtime libraries(mostly focusing on the UI aspects of JavaFX) were rewritten by a team that included some very talented developers from the Java Swing team In July 2008, the JavaFX Preview SDK was released, and at JavaOne 2008 Sun announced that the javaFX 1.0 SDK would be released in fall 2008 On December 4, 2008, the JavaFX 1.0 SDK was released This event increased the adoption rate of JavaFX by developers and IT managers because it represented a table codebase In April 2009, Oracle and Sun announced that Oracle would be acquiring Sun. The JavaFX 1.2 SdK was released at JavaOne 2009 In January 2010, Oracle completed its acquisition of Sun. JavaFX 1. 3 SDK was released in April 2010, with JavaFX 1. 3. 1 being the last of the 1. 3 releases the Web page noted in the Resources section below, and includes items such as the followi acle on At JavaOne 2010, JavaFX 2.0 was announced. The JavaFX 2.0 roadmap was published by o Deprecate the JavaFX Script language in favor of using java and the JavaFX 2.0 API This brings JavaFX into the mainstream by making it available to any language (such as Java, Groovy, and JRuby) that runs on the JVm Make the compelling features of JavaFX Script, including binding to expressions available in the javaFX 2.0 API Offer an increasingly rich set of UI components, building on the components already available in JavaFX 1.3 Provide a Web component for embedding html and javaScript content into JavaFX applications Enable JavaFX interoperability with Swing Rewrite the media stack from the ground up JavaFX 2.0 was released at JavaOne 201l, and has enjoyed a greatly increased adoption rate due to th le innovative features articulated previously now that you ve had the obligatory history lesson in JavaFX, let's get one step closer to writing code by showing you where some examples, tools, and other resources are Going to the Source: Oracle's JavaFX Web Site Oracle's JavaFX com site is a great resource for seeing example JavaFX programs, downloading the JavaFX SDK and tools, taking tutorials on JavaFX, and linking to other resources. See Figure 1-2 for a screenshot of this web site CHAPTER 1 GETTING A JUMP START IN JAVAFX JavaFX Learn Partner FAQ Get 230 Download Now a JavaFX 2.0 Bata SDK, JavafX 20 NetBeans Plugin an wa o V( Latest News s Updates Webcast: Enrich Your Enterprise Client Apps With JavaFX.0 WHATS NEW Article: Using Transitions for Animation in JavaFX 2.0 What's new in JavaFx 20 Beta Sign up for the JavaFX Partner Program JavaFx 20 Beta release now availadle s your company planning to build an application using JavaFX 2. 0? Wed like to help. Sign JavaFX 2.0 Roadmap and Festures Overview up for the JavaFX Partner Program and get access to development support, early access builds, priority feedback on bugs and co-marketing opportunities JDk 7 Developer Preview Release Now Available sign Up Now> Register for Javaone 2011 in San Francisco Why Use JavaFX What's New Benefits Get started Figure 1-2. Oracle's official JavaFX web site In addition, blogs maintained by Java FX engineers and developers are great resources for up-to-the minute technical information on JavaFX. For example, Oracle JavaFX Engineers Richard Bair, Jasper Potts, and Jonathan Giles keep the developer community apprised of the latest JavaFX innovations at http://fxexperience.comInadditiontheResourcessectionattheendofthischaptercontainsthe URLs of the blogs that the authors of this book use to engage the JavaFX developer community Take a few minutes to explore these sites. Next we point out some more valuable resources that are helpful Accessing the JavaFX SDK APl A useful resource available from the javafX sites is the sdK api javadoc documentation, shown in Figure 1-3 CHAPTER 1 GETTING A JUMP START IN JAVAFX Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED I FIELD I CONSTR I METHOD DETAIL: FIELD I CONSTR I METHOD javai scene. shape Class rectangle Java.lang CbJect 身又,叠,Ne组e 急f,ee,h是e,Sha色 javafx, scene, shape, Rectangle All Implemented Interfaces: EventTarget pb1五cc画 gs Rectangle extends The Rectangle class defines a rectangle with the specified size and location. By default the rectangle has sharp comers Rounded comers can be specified using the arc Width and arcHeight variables Example code the following code creates a rectangle with 20 pixel rounded comers mport Jav画fx,意cene,sh品pe, Rectangle r new Rectangle (): setX(50) Figure 1-3. JavaFX SDK API Javadoc The aPi documentation in Figure 1-3, for example, shows how to use the Rectangle class, located in the javafx scene. shape package Scrolling down this web page shows the properties, constructors, methods, and other helpful information about the rectangle class. By the way, this aPi documentation is available in the JavaFX SDK that youll download shortly but we wanted you to know how to find it online as well Now that you've explored Oracle's JavaFX web site and available resources, it's time to obtain the JavaFX SDK and related tools so that you can begin developing JavaFX programs Obtaining the JavaFX SDK You can get the JavaFX SDK from Oracles's JavaFX web site mentioned earlier. Currently you have the choice of downloading the JavaFX SDK, the JavaFX Runtime, and the JavaFX Plugin for NetBeans IDE. To develop JavaFX applications you'll need the JavaFX SDK. In addition, we recommend that you download the JavaFX Plugin for Net Beans idE as it contains modules that will help you develop and package JavaFX 2.0 applications. The instructions for the examples in this first chapter assume that you have the NetBeans plugin installed Go ahead and download the JavaFX SDK, and the JavaFX Plugin for Net Beans, following the installation instructions. In addition, so that you can compile and run the JavaFX application from the command-line, the JAR file that contains the JavaFXruntime must be on the classpath. The name of this file is jfxrt jar, and it is located in the rt/lib directory subordinate to the directory in which the JavaFX SDK is installed 6 CHAPTER 1 GETTING A JUMP START IN JAVAFX Other available tools There are other tools available for developing javaFX applications. For example, there is a JavaFX plug-in being developed by Tom Schindl for the Eclipse IDE, but at the time of this writing it isnt as mature as the NetBeans plugin. The URL for the Eclipse plugin is listed in the Resources section Now that you have the tools installed, we show you how to create a simple javaFX program, and then we walk through it in detail. The first program that we've chosen for you is called"Hello Earthrise, which demonstrates more features than the typical beginning Hello World"program Developing Your First JavaFX Program: " Hello Earthrise On Christmas Eve in 1968 the crew of Apollo 8 entered lunar orbit for the first time in history. They were the first humans to witness an"Earthrise, taking the magnificent picture shown in Figure 1-4. Thi image is dynamically loaded from this book's web site when the program starts, so you'll need to be connected to the internet to view it 图 Hello Earthrise Earthrise at Christmas: [Forty years ago this Christmas, a turbulent world looked to the Figure 1-4. The Hello earthrise program you two ways to do this from the command-line, and using Net Beans with the JavaFX plug i shows In addition to demonstrating how to dynamically load images over the Internet, this example she you how to use animation in JavaFX. Now it's time for you to compile and run the program. We Compiling and running from the command-Line We usually use an IDE to build and run JavaFX programs, but to take all of the mystery out of the process we use the command-line tools first 【实例截图】
【核心代码】

标签:

实例下载地址

JavaFX 2.0 電子書 - Pro JavaFX 2

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警