JavaFX UI Controls - JavaFX

What is JavaFX UI Controls?

Each user interface considers the following 3 major aspects −

  • UI Elements − these are the middle visible elements which the consumer finally sees and interacts with. JavaFX presents a big list of widely used and common elements various from fundamental to complex, which we can cover on this tutorial.
  • Layouts − They define how UI elements have to be prepared on the screen and offer a final appearance and feel to the GUI (Graphical person Interface). This component can be included in the layout chapter.
  • Behavior − those are events which arise when the person interacts with UI elements. This part can be included within the event handling chapter.

JavaFX gives numerous classes within the package javafx.scene.control. To create numerous GUI additives (controls), JavaFX helps several controls together with date picker, button text field, etc.

Every Manage is represented through a class; you may create a manage through instantiating its respective class.

Following is the list of generally used controls while the GUI is designed using JavaFX.

S.No

Control & Description

1

Label

A Label object is a component for placing text.

2

Button

This class creates a labeled button.

3

ColorPicker

A ColorPicker provides a pane of controls designed to allow a user to manipulate and select a color.

4

CheckBox

A CheckBox is a graphical component that can be in either an on(true) or off (false) state.

5

RadioButton

The RadioButton class is a graphical component, which can either be in a ON (true) or OFF (false) state in a group.

6

ListView

A ListView component presents the user with a scrolling list of text items.

7

TextField

A TextField object is a text component that allows for the editing of a single line of text.

8

PasswordField

A PasswordField object is a text component specialized for password entry.

9

Scrollbar

A Scrollbar control represents a scroll bar component in order to enable user to select from range of values.

10

FileChooser

A FileChooser control represents a dialog window from which the user can select a file.

11

ProgressBar

As the task progresses towards completion, the progress bar displays the task's percentage of completion.

12

Slider

A Slider lets the user graphically select a value by sliding a knob within a bounded interval.

Example

The following program is an example which shows a login page in JavaFX. right here, we are using the controls label, text field, password field and button.

Save this code in a report with the name LoginPage.java.

Collect and execute the saved java file from the command prompt using the following commands.

On executing, the above program generates a JavaFX window as shown below.

JavaFX UI Controls

The following program is an example of a registration form, which demonstrates controls in JavaFX including Date Picker, Radio Button, Toggle Button, test box, list View, preference list, etc.

Save this code in a file with the name Registration.java.

Collect and execute the saved java file from the command prompt using the following commands.

On executing, the above program generates a JavaFX window as shown below.

JavaFX UI Controls

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JavaFX Topics