Book Image

JavaFX Essentials

By : Mohamed Taman, Mohamed Taman
Book Image

JavaFX Essentials

By: Mohamed Taman, Mohamed Taman

Overview of this book

Table of Contents (16 chapters)
JavaFX Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
7
Monitoring and Controlling Arduino with JavaFX
Index

Preface

This book, as its title (JavaFX 8 Essentials) suggests, is a pragmatic book that provides you with a robust set of essential skills that will guide you to become confident enough to rapidly build high-performance JavaFX 8 client applications. These applications take advantage of modern GPUs through hardware-accelerated graphics while delivering a compelling, complex, and fancy rich-client GUI for your customer, which will impress them quite a bit.

Learning the JavaFX 8 essentials is the first step to plunging into creating applications that most importantly run on any platform, from the desktop, Web, mobile, tablets, to embedded devices such as Arduino, Raspberry Pi, and multi-core development. Following Java's Write once, run anywhere paradigm, JavaFX also preserves the same. Because JavaFX 8 is written totally from scratch in the Java language, you will feel at home.

Most of the chapters are a fast-paced guide that will help you get a head start on Java GUI programming, leveraging JavaFX 8 and deploying and running on any platform.

While working through the book examples, you will find code is written with JavaFX 8 on Java 8 (yes, Java SE 8) so that the new APIs and language enhancements will help you become a more productive developer. Having said this, it will be handy (and I encourage you to go for this) to explore all of the new Java 8 capabilities.

Finally, yet importantly, you will be able to develop amazing touch-less interactive motion applications with JavaFX that interact with Leap motion devices.

What this book covers

Chapter 1, Getting Started with JavaFX 8, is an introduction to JavaFX 8. It discusses JavaFX 8 as a technology, why you should care about it, its history, core features, and where it can be used.

So it is time to get ready with the right tools and go through the necessary steps to install JavaFX 8 and its supporting development tools. Learn about additional tools that will increase reader productivity in this chapter. As a final verification that we are on the right track, we are going to close the chapter with a simple Hello JavaFX application.

Chapter 2, JavaFX 8 Essentials and Creating a Custom UI, discusses how there is nothing more frustrating than receiving complicated advice as a solution to a problem. Because of this, I have always made it a point to focus on the essentials. In order to render graphics on the JavaFX scene, you will need a basic application, scene, canvas, shapes, text, controls, and colors.

Also, you will learn about JavaFX 8 essential application structures that serve as a backbone to any future application. And finally, we will also explore some Java SE 8 features (such as Lambda, Streams, JavaFX Properties, and so on) to help increase code readability, quality, and productivity.

After getting hands-on experience in creating a structured JavaFX 8 application, wouldn't it be nice if you could change the UI of your application without altering its functionality? In this chapter, you will learn about theming and how to customize applications by applying various themes (look and feel) and the fundamentals of JavaFX CSS styling.

You will use Scene Builder to create and define UI screens graphically and save them as a JavaFX FXML-formatted file. Finally, you will learn about creating custom controls.

Chapter 3, Developing a JavaFX Desktop and Web Application, covers on how to develop a compelling desktop and Web application that takes advantage of multi-core hardware accelerated GPUs to deliver a high performance UI-based application with an amazing appearance.

As JavaFX is totally written from the ground up in Java, some Java SE 8 built-in core libraries will be used to power our application. Also, you will learn how to package your application as a standalone application to be launched and distributed.

In addition, we will cover the essential core web APIs in any web application levered by JavaFX 8, such as javafx.scene.web.WebEngine and javafx.scene.web.WebView.

We will also discuss the relationship between JavaFX and HTML5, which is important because they complement each other. JavaFX's rich client APIs, coupled with HTML5's rich web content, create a user experience resembling a RIA Web application with the characteristics of native desktop software.

Chapter 4, Developing a JavaFX Application for Android, as we see a rise in non-pc clients, mobile phones and tablets are gaining market share. JavaFX 8 can deliver a rich client application for Web and desktop. If you write a JavaFX application, make sure you want it to run on as many devices as possible. This chapter will give you essential hands-on experience and knowledge about SDKs that allow users to create native applications for Android mobile phones.

Chapter 5, Developing a JavaFX Application for iOS, is an extension to the previous chapter. If you write a JavaFX application for Android, be sure you want it to run on as many iOS devices as possible. This chapter will give you essential hands-on experience and knowledge about SDKs that allow them to create native applications for Apple iOS.

Chapter 6, Running JavaFX Applications on the Raspberry Pi, will provide you with all the necessary skills and knowledge to develop a JavaFX 8 application that runs on a credit card-sized computer, the Raspberry Pi board. As the Internet of things (IoT) has become a hot topic of late. Java was made for the Internet of things literally.

Chapter 7, Monitoring and Controlling Arduino with JavaFX, covers another kind of Internet of everything (IoT). Arduino is an open-source electronics prototyping platform, delivering low-cost prototyping platforms to support both the do-it-yourself concept and the maker movement.

This chapter will provide you with all the necessary skills and knowledge to quickly use JavaFX along with an Arduino board to develop desktop applications for monitoring data coming from the real world or controlling real devices.

Chapter 8, Interactive Leap Motion Apps with JavaFX, will make you learn about gesture recognition. You will discover an awesome gadget, the Leap Motion device, which will allow a touch-less approach to develop enhanced JavaFX applications.

Machine user input interfaces are becoming increasingly less mouse-centric, in favor of multi-touch and even touch-less input. Gestures are one of the ways humans can communicate with machines naturally these days.

Appendix, Become a JavaFX Guru, will make you find many useful links and references that will help you gain further knowledge about all things JavaFX.

At the end of this chapter, make sure to check out the many frameworks, libraries, and projects that use JavaFX in production today.

What you need for this book

The examples given in this book utilize the latest release of Java SE 8 at the time of writing, namely the Java SE 8 update 45 JDK edition. Starting with Java SE 8, it comes pre-bundled with the JavaFX 8 that we use throughout this entire book. Also, NetBeans IDE version 8.0.2 is used as an Integrated Development Environment, as well as the JavaFX designer tool Gluon Scene Builder version 8, as general software and tools.

As each chapter is unique in its nature and requires specific software and hardware for the JavaFX 8 examples to run normally, this book provides all the required software, tools, and hardware with detailed explanation on how to install and configure them, in order to run JavaFX 8 examples smoothly.

Who this book is for

If you are a Java developer, an experienced Java Swing, Flash/Flex, SWT, or a web developer looking to take your client-side applications to the next level, this book is for you. This book will put you on the right track to begin creating a fancy, customizable, and compelling user interface.

Also, you will learn how to create high-performance rich client-side applications rapidly that run on any platform, be it desktop, web, mobile, or embedded systems, such as Raspberry Pi, Arduino, and applications based on the touch-less Leap Motion.

This book is a fast-paced guide that will help you get a head start on Java GUI programming leveraging JavaFX 8, deployed and runs on any platform.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

btn.setOnAction(new EventHandler<ActionEvent>() {
  @Override
  public void handle(ActionEvent event) {
    message.setText("Hello World! JavaFX style :)");
  }
});

Any command-line input or output is written as follows:

$ gradle build

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on Install to begin the installation".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/8026OS_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.