Questions tagged [javafx]

The JavaFX platform enables developers to create and deploy Graphical User Interface (GUI) applications that behave consistently across multiple platforms. JavaFX 1.3 and older, were scripting languages, whereas JavaFX 2.x+/8.x enables users to use Java. FXML enables JavaFX to follow an MVC architecture.

The JavaFX platform enables developers to create and deploy Graphical User Interface (GUI) applications that behave consistently across multiple platforms. It is built on java technology and was part of the Oracle JDK from JDK 8 until Java 10. Since JDK 11, JavaFX is shipped as a library, independent of most JDK and JRE distributions.

External Resources

Tag Usage

  • javafx accumulates questions on all version as it tends to be used on the current version at the time the question is asked.
  • javafx-18 is dedicated to questions that are specific to the JavaFX 18 version.
  • javafx-17 is dedicated to questions that are specific to the JavaFX 17 version.
  • javafx-11 is dedicated to questions that are specific to the JavaFX 11 version.
  • javafx-8 is dedicated to questions that are specific to the JavaFX 8 version.

Outdated tags - do not use, instead update your environment to a recent version

  • javafx-2 is dedicated to questions that are specific to the JavaFX 2+ version.
  • javafx-1 is dedicated to questions that are specific to JavaFX 1.x releases which used JavaFX Script language

Frequently Asked Questions

People often ask these questions about this topic:

Installation

Resource Lookup

FXML

Packaging

Virtualized Controls

Misc

38047 questions
67
votes
3 answers

Label and Text differences in JavaFX

What is the difference between javafx.scene.text.Text and javafx.scene.control.Label? The documentation says: Label is a non-editable text control. The Text class defines a node that displays a text. But the Label class has a method "setText"…
Marlord
  • 1,144
  • 2
  • 13
  • 24
67
votes
9 answers

close fxml window by code, javafx

I need to close the current fxml window by code in the controller I know stage.close() or stage.hide() do this in fx how to implement this in fxml? I tried private void on_btnClose_clicked(ActionEvent actionEvent) { Parent root =…
alfredo138923
  • 1,509
  • 1
  • 15
  • 15
66
votes
7 answers

How to avoid Not on FX application thread; currentThread = JavaFX Application Thread error?

Below code snippets is giving me error Not on FX application thread; currentThread=JavaFX Application Thread.This application was working fine in java 1.7 but when i moved it to fx8 it is now giving error. when I start the application on my 1st…
Rajesh Kumar Dash
  • 2,203
  • 6
  • 28
  • 57
63
votes
2 answers

Disabling a Button in JavaFX

In Swing, we can disable a button like this: JButton start = new JButton("Start"); start.setEnabled(false); Is there anyway to do this with a JavaFX Button? The user should only be able to press the button once.
Tarif Haque
  • 833
  • 1
  • 11
  • 16
62
votes
4 answers

JavaFX: Stage close handler

I want to save a file before closing my JavaFX application. This is how I'm setting up the handler in Main::start: primaryStage.setOnCloseRequest(event -> { System.out.println("Stage is closing"); // Save file }); And the controller calling…
Heine Frade
  • 723
  • 1
  • 5
  • 4
62
votes
3 answers

How perform task on JavaFX TextField at onfocus and outfocus?

I am working on JavaFX project. I need to perform some task on a JavaFX TextField. For example on the "on focus" event for the TextField I want to print System.out.println("Textfield on focus"); and on the "out focus" event it should…
java baba
  • 2,199
  • 13
  • 33
  • 45
62
votes
11 answers

Javafx 2 click and double click

I would like to know if it was possible to detect the double-click in JavaFX 2 ? and how ? I would like to make different event between a click and a double click. Thanks
Delkaspo
  • 768
  • 1
  • 6
  • 10
61
votes
2 answers

How do I resize an imageview image in javafx?

I need to resize an image to specific dimensions, 100 by 100 pixels for example, in JavaFX. How can I achieve that? Could the Image or the ImageView class be used for this purpose?
Jeremy
  • 613
  • 1
  • 5
  • 5
61
votes
2 answers

Remove the default 'no content in table' text for empty javafx table

I would like to remove or change the default text shown by an empty javafx table from No content in table to something more meaningful for the user. For example in a table showing students, when there are no students to show I want it to say "No…
58
votes
4 answers

What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?

I'm trying to run some JavaFX code with Eclipse Kepler, with e(fx)clipse plugin installed, on a Linux machine, using: java version "1.7.0_21" OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-5) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed…
Marco Lackovic
  • 6,077
  • 7
  • 55
  • 56
57
votes
2 answers

Packaging jar is invalid Aggregator project need pom as packaging

My project has different modules. Each module has a pom.xml which specifies jar packaging. Each pom refers to common parent. In the parent module there is also a pom.xml which includes all the modules. When I tried to package using the pom.xml of…
Anvay
  • 1,923
  • 2
  • 18
  • 19
56
votes
2 answers

How to resize JavaFX ScrollPane content to fit current size

I have a BorderPane with a ScrollPane as the center element. It resizes automatically to fill the screen. Inside the ScrollPane is a HBox that has no content but is a drag-and-drop target. Therefore I want it to fill its parent ScrollPane. What is…
Lennert
  • 925
  • 1
  • 7
  • 21
55
votes
1 answer

Value Change Listener for JavaFX's TextField

I would like to add a kind of listener to my JavaFX's TextField which when ever a user changes the value of the TextField, the Application prints something on the console. I've searched and i find the following very similar question : Value Change…
Elyas Hadizadeh
  • 3,289
  • 8
  • 40
  • 54
53
votes
6 answers

How do I remove the default border glow of a JavaFX button (when selected)?

I'm trying to remove the border glow (please see screenshot below) that appears by default when a JavaFX button is selected: I also want to do this using CSS, and not declaratively from within the main JavaFX script. However, I am having trouble…
Titus
  • 4,487
  • 6
  • 32
  • 42
53
votes
2 answers

Applying MVC With JavaFx

I'm new to the GUI world/OO design pattern and I want to use MVC pattern for my GUI application, I have read a little tutorial about MVC pattern, the Model will contain the data, the View will contain the visual element and the Controller will tie…
KarimS
  • 3,812
  • 9
  • 41
  • 64