Preface

Welcome to Rich Internet Application development with JavaFX.

This book is about creating more engaging user applications using special effects and animation. In this book, we will focus on using JavaFX for creating Rich Internet Applications.

Building upon the widely adopted and popular Java Platform, JavaFX provides a new level of abstraction that greatly simplifies graphical user interface development while at the same time bringing all the flexibility that Java technologies provide. This creates an elegant, yet powerful, platform for building full feature and compelling applications.

What Is JavaFX?

JavaFX is actually a family of products developed at Sun Microsystems. There are initiatives for mobile phones, consumer, television, and desktop devices. The cornerstone to these projects is JavaFX. JavaFX is a platform that includes a high performance declarative scripting language for delivering and building a new generation of Rich Internet Applications.

The primary focus of JavaFX is to make graphical user interface development easy while embracing more compelling features like visual effects, sound, and animation. JavaFX includes a ready-made framework to support graphic components and to easily include multimedia features like pictures, video, audio, and animation. Using the Java platform at its core, JavaFX works seamlessly with the Java platform and can easily leverage existing Java code. This also allows JavaFX to leverage the “write once, run anywhere” capability provided with the Java platform.

Why JavaFX?

Anyone who has ever written a graphical user interface application can appreciate the complexity of creating such an application. Though the resulting user interface can produce a powerful user experience, developing a cool application can be a daunting task. It takes a skilled developer who knows the graphical language and framework inside-out to pull off a well-written UI. JavaFX addresses this complexity.

Furthermore, graphic design and programming are two distinct skills. Graphic designers focus on the human interaction with the application, and are more interested in keeping the human’s interest and making the system intuitive. On the other side, the program developers are typically concerned with implementing business logic and interacting with back-end servers. It is a rare breed that masters both of these skills. JavaFX’s goal is to bridge these two crafts by allowing the graphic designer to dabble in an easily understood programming language, while at the same time allowing the developer the flexibility to implement the business rules behind the user interface.

JavaFX does this by

•   Simplifying the programming language

•   Providing ready-built user interface components and frameworks to support UI creations

•   Making it easy to update existing UI applications

•   Providing a cross-platform environment that delivers on “Write Once, Run Anywhere”

Rich Internet Applications

For many years, the programming paradigm has been centered on a client-server architecture employing a “thin” client. In this architecture, most of the processing was in the server with the client merely displaying the content. In a thin client system, data must be transmitted to the server for processing and a response sent back. This is very true of the HTML screens introduced with the original Internet browsers. However, by leveraging compute power on the client side, it is now possible to perform actions on the client, thereby reducing the round-trip latency to the server.

A Rich Internet Application is an application that allows a good portion of the application to execute on the user’s local system. Primarily, the client application is designed to perform those functions that enhance the user’s experience. Furthermore, communications with the server do not have to be initiated from a user action, like clicking on a button. Instead, a server itself can update the client with fresh content asynchronously as needed and without waiting for the end user to perform some action or by employing other tricks in the client like periodically polling the server.

So what is old is new again. In a sense this is true, but this really represents an evolution of the client server paradigm rather than a retrenchment back to the old days of the monolithic program that did everything. The key to a Rich Internet Application is striking the proper balance between behavior that should stay on the client with the behavior that rightfully belongs on the server. JavaFX is a framework that embraces the Rich Internet Application model.

Why This Book?

JavaFX is a new technology and we set out to help you get started quickly by exploring key features of JavaFX and how it should be used. We purposely did not want to do a language reference document as the language itself is fairly simple. Our main goal is to help you to quickly and productively create cool user interfaces.

This book’s primary audience is comprised of developers (of all levels) and graphic designers who need to build Rich Internet Applications. There are different types of developers and designers that this book targets:

•   Java developers who are currently building Rich Internet Applications with Java Swing

•   Java developers who are interested in learning JavaFX for future projects

•   Non-Java application developers who wish to use JavaFX for Rich Internet Application development

•   Graphic designers, animators, or motion-graphic designers who wish to use JavaFX to add special effects, animation, and sound to their creations

How to Use This Book

This book has thirteen chapters. The first four chapters cover the basics of JavaFX, how to get started, what the graphic designer’s role is, and the basic language. The next five chapters cover the advanced features you expect in a Rich Internet Application. These include basic UI design, special effects, animation, multimedia, and browser display. Chapter 10 covers using JavaFX in a Web Services architecture. Chapter 11 describes JavaFX’s interaction with the Java platform and assumes you are knowledgeable about Java. The last two chapters cover JavaFX code recipes and a complete Sudoku application.

We have used a building block approach with basic concepts covered first and more complex features addressed later in the book, so we suggest you read each chapter in sequential order. If you are a graphic designer, you may be more interested in Chapter 2. You can safely start there, then jump back to Chapter 1 to dig deeper into JavaFX. If you are an “über”-coder, you can safely skip Chapter 2, but we still suggest you eventually read it just to know what the “dark” side is doing. Chapter 11 assumes you have a good understanding of the Java platform and APIs. If you do not plan to comingle your Java classes with JavaFX source in your application, you can safely skip this chapter. The last two chapters show some code examples based on the foundations laid down in the earlier chapters.

Here’s the book in a nutshell:

•   Chapter 1: Getting Started. This chapter gets you set up and shows the basics of creating and running a JavaFX program.

•   Chapter 2: JavaFX for the Graphic Designer. This chapter explains how a graphic designer would use JavaFX to create JavaFX Graphical Assets.

•   Chapter 3: JavaFX Primer. This chapter covers the basic JavaFX Script syntax.

•   Chapter 4: Synchronize Data Models—Binding and Triggers. JavaFX Script introduces a data binding feature that greatly simplifies the model-view-controller design pattern. This chapter explains the concepts of data binding in the JavaFX Script language.

•   Chapter 5: Create User Interfaces. The primary focus of JavaFX is to create rich user interfaces. This chapter explores the visual components available to create user interfaces and demonstrates how the features of JavaFX work together to produce a rich user experience.

•   Chapter 6: Apply Special Effects. A key to Rich Internet Applications is applying cool special effects to bring user interfaces alive and make them appealing to use. This chapter explores the special effects that JavaFX provides, including lighting, visual, and reflection effects.

•   Chapter 7: Add Motion with JavaFX Animation. Animation makes the user interface vibrant and interesting. This chapter explains the concepts behind the JavaFX animation framework and provides examples of fade in/out, color animation, and motion. It also demonstrates an animation using Graphical Assets generated by the graphic designer.

•   Chapter 8: Include Multimedia. This chapter explores how to include pictures, sound, and videos in your application.

•   Chapter 9: Add JavaFX to Web Pages with Applets. (Applets are back and these are not your father’s applets.) This chapter explores embedding JavaFX applications within Web pages and shows how to undock the applet from the Web page and demonstrate interaction with JavaScript.

•   Chapter 10: Create RESTful Applications. JavaFX provides frameworks for working easily with JavaScript Object Notation (JSON) and Extensible Markup Language (XML). This chapter explores both options.

•   Chapter 11: JavaFX and Java Technology. This chapter explores how JavaFX interacts with the Java platform.

•   Chapter 12: JavaFX Code Recipes. Code recipes are general reusable solutions to common situations in programming. This chapter provides an overview of some code recipes applicable to programming JavaFX applications.

•   Chapter 13: Sudoku Application. This chapter explores creating a Sudoku game application in JavaFX.

As we introduce topics, we have tried to inject our own experiences to help you avoid trial and error kinds of mistakes and “gotchas.” Throughout the chapters, we have sprinkled Developer Notes, Warnings, and Tips to point out things that might not be obvious. We have also tried to include as many examples and figures as possible to illustrate JavaFX features and concepts.

This book is intended to cover the general deployment of JavaFX, whether it be on the desktop, mobile, or eventually the TV profiles. However, there is a bias toward the desktop version and specific features for JavaFX mobile are not covered. Still, the basic concepts and features covered in this book will also apply to these other profiles and to future releases of JavaFX.

Staying Up-to-Date

This book is written to the JavaFX 1.1 Software Development Kit (SDK). As this book goes to press, JavaFX 1.2 is being finalized. We have tried to include as many JavaFX 1.2 features as possible; however, not all features were fully defined in time. Please check out the book’s Web site, http://jfxbook.com, for updates for the JavaFX 1.2 release.

This book is jam packed with demo and example code. To illustrate some features in print, we have abbreviated some of the examples. The complete code used in this book is available on the book’s Web site at http://jfxbook.com. You can also check this site for updates, errata, and extra content. There is also a forum for sharing information about the book and JavaFX.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset