JavaFX Playbook - Labeled and Text Controls

JavaFX is the go-to UI library in the Java ecosystem. This course teaches you how to use labeled and text input controls from simple to complex use cases right from the creation and customization until event handling.
Course info
Level
Intermediate
Updated
May 11, 2018
Duration
2h 20m
Table of contents
Course Overview
Introduction and Preparation
Label: Styling
Event Binding
Labeled Controls: Button
Labeled Controls: ToggleButton
Labeled Controls: RadioButton
Labeled Controls: CheckBox
Labeled Controls: Hyperlink
Labeled Controls: MenuButton
Text Input Controls: TextField
Text Input Controls: PasswordField
Text Input Controls: TextArea
Text Input Controls: HtmlEditor
Mnemonics and Accelerators
Tooltips
Description
Course info
Level
Intermediate
Updated
May 11, 2018
Duration
2h 20m
Description

At the core of developing desktop applications using JavaFX is a thorough knowledge of controls. In JavaFX Playbook: Labeled and Text Controls, you will learn how to use the 12 most common controls in order to create useful applications. First, you will learn about labeled controls, which also includes buttons and hyperlinks. Next, you will explore text input controls that are primarily used for reading keyboard input from the user with the help of text fields, text areas, or similar controls. Finally, you will discover how to use some common functionality among these controls, such as tooltips and accelerators. When you are finished with this course, you will have a foundational knowledge of creating, styling, and customizing labeled and text input controls that will help you as you move forward to develop effective desktop applications using JavaFX.

About the author
About the author

Buddha Jyothiprasad is an Author with Pluralsight and has more than 10 years of experience in software development. Previously worked with IBM & Oracle and now works as a Developer at Amazon.

More from the author
JavaFX Playbook: Controls with Data Model
Intermediate
2h 58m
Aug 31, 2018
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
JavaFX has lots of controls that can be used without much customization. Each control comes with numerous ways to customize them to suit the requirements of your needs. However, not much documentation is available on how to use these controls, and the small amounts of available information is scattered throughout the internet. In this course, I will take you through a demonstration of labeled and text input controls. Labeled controls are comprised of various kinds of buttons, labels, and hyperlinks. The text input controls deal with the use cases where you have to read the input from the user. We'll work on a simple scratch pad application and show how to customize these controls to handle many use cases. This course takes a playbook approach, so you can pick any module provided that you have completed module 1. There is no relationship between modules except for the fact that every module starts from the same starting point, making it easy for people who don't like to follow a top-down approach in completing the course. This also helps you pick any module that deals with the control of your interest. If you only want to learn about HtmlEditor and learn how to add new functionality to it, go ahead and start at module number 13. If you want to learn how to use RadioButtons, open the sixth module. Once you've finished the first module, you can follow your heart's desire. In order to complete this course, you should be familiar with Java and have used IntelliJ IDEA as an IDE, but you should be able to follow along these demos in any IDE Of your choice. You also need to have JavaLite installed in your machine, and basic familiarity with XML will help you understand the FXML easily. So, if this sounds like fun, hop on and let's share the ride.

Introduction and Preparation
Hi, this is Buddha Jyothiprasad from Pluralsight. Welcome to the course JavaFX Playbook - Labeled and Text Controls. JavaFX is the recommended choice for building desktop applications in Java space. In this course, I'm going to take you over many controls that exist in JavaFX in a detailed fashion. Each module is dedicated to a focused topic or control. This course is first of many other courses to come in a playbook format dealing with controls of JavaFX. In this format, you can pick and choose any module once you have completed the first module. The first module forms the basis for each and every other module. All the demos in every module began from where we left off in module 1 so you can pick any module of your choice and complete it without having to worry about missing pieces. If you have some questions regarding a control, go to the module of interest. In this course, I'm going to take you over labeled and text input controls. I will be using IntelliJ IDEA, but you can choose any IDE of your liking. This course starts with an assumption that you are already aware of how to write a Hello World kind of program in JavaFX and have the environment ready. If you want to understand how to install Java and set up an IDE, please go to the existing course, Building Your First JavaFX Application.

Label: Styling
In the previous module, we have looked at some basics of JavaFX and created a playground for us to try different controls. In this module, we will look at the simplest control of all, the label. However, we will only look at styling part of the label control. We will create a label and decorate it using styles and effects. We will also understand how to display images with the help of Image and ImageView classes. Let's just jump into it without any further ado.

Event Binding
In the previous module, you have seen how to apply styles to label. We just played like children with crayons filling fancy colors and effects, but everything is static and not so useful. Let us dial it up a notch and see how to make our application react to user actions at runtime. Event binding is the holy grail of any application development, and no application can be complete without it. What we learn here is not just applicable to label, but to all kinds of controls. So, without any delay, let us get to it right away. Let us first take a look at what we are going to cover in this module. We'll first begin with understanding what events are and how to handle events using event handlers. We will see some examples like mouse entered, mouse exited, etc. , and learn another interesting event, the drag and drop event, which is a bit complex, but once you understand how to do drag and drop it'll be pretty easy to handle any other events.

Labeled Controls: Button
Hi. Welcome to another module of the course JavaFX - Labeled and Text Input Controls. In this module, we will cover another label control, Button. In my view, Button is the most important control that can be during any application. Without Button, we'll find it very difficult to actually ask the computer to do anything at all. In this module, we will first see how to create a Button object using the FXML, JavaFX API, etc. , and understand how to handle action, as well as events.

Labeled Controls: ToggleButton
Hi. In this module we will learn about ToggleButton, which is another labeled control. You may already be familiar with the concept called as RadioButton or CheckBox, which provides the ability for the user to either select or unselect an item. ToggleButton works very similar to that. In this module, we will begin with understanding the ToggleButton control, and then we will go ahead and understand how to use ToggleGroups, which is a way to group multiple ToggleButtons.

Labeled Controls: RadioButton
Hi. In this module we will learn about RadioButton. RadioButton is a control that is extensively used in almost all user interfaces. In every form that you fill, there is a very high chance of using a RadioButton. So in this module we will understand how to create and use the RadioButtons. Along with that, we will also see how we can use the concept of ToggleGroups to combine multiple RadioButtons for mutual exclusion.

Labeled Controls: CheckBox
In this module, we will handle another important control, CheckBox. CheckBox allows to use as to select or unselect an option. Unlike RadioButton, this doesn't provide mutual exclusion. You can select as many number of CheckBoxes as you want, but as in RadioButton you can only select one of the options in a single ToggleGroup. By completing the module, you will understand how to use CheckBoxes to present users with options where they can select 0 or more. In this module, we will see how to create the CheckBoxes using FXML and JavaFX API, and then we will understand how to detect changes so that we can run a piece of code when the user selects or deselects a checkbox. We will also cover the indeterminate state in the demo.

Labeled Controls: Hyperlink
Hi. In this module, we will cover another Labeled control, Hyperlink. You may have seen many hyperlinks when navigating the web. When you search in Google, you will see the hyperlinks of hundreds of web pages that are matching the search criteria. You click on a link to go to a specific web page. In JavaFX world, hyperlink is very much similar to a button. You click on it, and a piece of code gets executed no different than a button. But why do we have another control called as Hyperlink? If you remember, in web, when you visit a specific page it remembers whether you have already visited that page or not, and shows that hyperlink in slightly different style. It's all similar stylistic purposes in JavaFX as well. We will begin with understanding how to create Hyperlinks, and then how to detect the clicks on the Hyperlinks. And just like how web links remember whether they are visited or not, JavaFX Hyperlinks also remember the visited status. We will see how to use the visited status and how to reset its visited status.

Labeled Controls: MenuButton
In this module, we will see another interesting control, MenuButton. A MenuButton looks very similar to a combo box, but it really isn't one. A MenuButton is essentially a list of actions that you can choose from. In this module, we will begin with understanding where we can use a MenuButton, and then we will add menu items to a MenuButton dynamically, as well as statically.

Text Input Controls: TextField
Hi. In this module we will start with a Text Input Control. TextField is one of the simplest TextInputControls that are there. it's just a rectangular area that asks the user to type in some text. TextField is very prominent in any of the applications that you use. It may be a login form where you enter username, it may be a field where you type your age, or it may be something else. I don't think you can develop any application without it. In this module, we will cover various aspects of the TextField and see how we can use this TextField. Along with simple use cases, we will also see some advanced concepts like text formatters for a TextField.

Text Input Controls: PasswordField
Hi. In this module we will deal with another important control, PasswordField. Whenever you want the user to enter sensitive information like password, credit card number, SSN, etc. , you don't want to display the text that is typed by the user for obvious reasons. This is where PasswordField comes in. In this module, I will show how to use PasswordField, be it reading from the PasswordField or setting a value in the PasswordField. JavaFX, by default, doesn't allow you to display what characters are typed in, so I'm going to show you a neat little trick using which you can implement the feature similar to show characters. Let's quickly get to those.

Text Input Controls: TextArea
Hi. In this module, we will take a look at TextArea. You might have already seen the modules about TextField and PasswordFields. They both allow the users to enter text, or in other words they allow the users to type the text. TextArea is very similar to that, it also allows the users to type in text, but it is intended for multiline input, In this short module, we will quickly see how to use TextArea and compare it with TextField.

Text Input Controls: HtmlEditor
Hi. In this module, we will take a look at HtmlEditor. All the TextInput Controls you may have seen so far in the previous modules are just there for asking the user to enter an input. You can style the textbox itself, but none of them allow you to style the text as well as you may want. Either you can set the entire text color to be blue or something like that, but if you want one word to be blue and another word to be red, you cannot do that. That is where the HtmlEditor comes into the picture. In this module, we will see how to use the HtmlEditor, and understand the differences with the TextArea. And then we will also see how we can customize HtmlEditor to add in more functionalities to it.

Mnemonics and Accelerators
Hi. So far, we have looked at different kinds of controls. In this module, we will do something different. We will not cover any control, but we will cover some common concepts that are applicable for many of the controls, especially mnemonics and accelerators. You may be familiar with many applications, but every application will have some common things like shortcuts. Whenever you press Command+S or Ctrl+S it will be saving the file, which is a very famous one. Whenever you press Command+O or Ctrl+O, it will be opening an open file wizard. Just like that, there is Ctrl+C and Ctrl+V, which are used even more frequently than the Save and Open. We can do all these things with the help of mnemonics and accelerators. In this module, we will first begin with understanding what mnemonics are, and then we will see how we can use something called labelfor attribute to use fields that doesn't have mnemonics. And then we will understand what accelerators are, and with the help of accelerators we will create various keyboard shortcuts for our application. Let us just jump into it quickly.

Tooltips
Hi, welcome to the final module of the course, JavaFX Playbook - Labeled and TextInput Controls. In this module, we will deal with another common phenomenon, Tooltips. You can obviously build very complex UI that looks very good and all, but sometimes the user may not understand what your intention is upon creating a button with a cute little smiley, or it may not look so appealing to the user. In order to provide more information to it without actually putting any text onto the control, that is where Tooltips come into play. In this module, we will understand what Tooltips are and how we can create and install the Tooltips. And then we will build a little complex Tooltips by putting an image inside the Tooltip.