Questions tagged [fxml]

a scriptable XML-based language that provides the structure for building a JavaFX user interface separate from the application logic of your code.

FXML was introduced with the release of JavaFX 2.0 in 2011 by Oracle. It's rich XML-based language to declare JavaFX UI in structured format.

Using FXML allows to separate logic from presentation which is very welcome in modern MVC world.

In addition to straightforward UI declaration FXML allows:

  • using Controller for seamless mapping of the XML entities to the JavaFX objects.
  • referring property files (e.g. for i18n support)
  • introducing variables
  • setup complex object by referring static method calls
  • work with collections
  • even using JavaScript or other scripting languages

A good start to learn more about the format would be the Oracle article JavaFX: Mastering FXML.

3561 questions
5
votes
2 answers

Which ChoiceBox-Event to choose?

I placed a ChoiceBox inside an fxml with JavaFX Scene Builder. The FXML has a controller assigned to it. My question is: Which event do I need to register if I want to know about changed…
Gundon
  • 2,081
  • 6
  • 28
  • 46
5
votes
2 answers

JavaFX2 FXML how to add elements (e.g. Buttons) dynamically

So, what I want to do is, creating a custom element by using fxml and then add a couple of instances of that element into a container, like GridPane. The "new" operators does not work for me, because I would like to use the @fxml annotator to get…
user1562969
  • 155
  • 1
  • 2
  • 7
4
votes
1 answer

How to add an icon to the Tab control in FXML?

I'm using javafx 2.0. I want to add an icon to the Tab in fxml: example:
fxuser
  • 299
  • 1
  • 6
  • 16
4
votes
1 answer

JavaFX: Exception in Application Start Method java.lang.reflect.InvocationTargetException

I am literally desperate. I don’t know why but every time I try to run my program this error comes out. I am using Netbeans, with Java 10.0.2 in order to have already installed JavaFX. I think it’s due to some problem with the FXML file. Can you…
4
votes
1 answer

Error assigning a boolean value in a custom class extends from TextField (FXML)

I started learning JavaFX and ran into this problem: I have a TextBox class extendsfrom TextField package sample; import javafx.fxml.FXML; import javafx.scene.control.TextField; public class TextBox extends TextField { private int maxLength =…
4
votes
2 answers

How to make Label take same height as font size in JavaFX?

I set the font size of upper label to 24px. I don't know where I can check the real height of element (if it's possible in the Scene builder), but there is the extra space in upper (designated in the image) and lower part of box. The line spacing…
Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
4
votes
1 answer

Access modifiers in JavaFx and @FXML

I am new to JavaFx and in a few tutorials I've seen, there were some differences. In one of the tutorials, he always used private as the access modifier in the controller class and wrote it this way: @FXML private Button button; But the other…
arty
  • 609
  • 1
  • 6
  • 12
4
votes
3 answers

How to fix "Unable to derive module descriptor for .jar file" error in fxml

I would like to get an image from JAR library to my project. I've added the library to my module and…
user11383582
4
votes
1 answer

FXMLLoader.load() works fine in pre-java 9 style, but fails in modules

I successfully made a simple JavaFX FXML program (in pre-Java 9 style, not module) I used 3 files and the main class as below: └───javafxfxmldemo FXMLDocument.fxml FXMLDocumentController.java JavaFXFXMLDemo.java Main…
KBee
  • 87
  • 1
  • 5
4
votes
2 answers

JAVA 11 and JavaFX in IntelliJ IDEA

I created JavaFX project in IntelliJ IDEA 2018. I have installed Java JDK 11 and my project (Maven) includes all needed dependencies: org.openjfx
Baterka
  • 3,075
  • 5
  • 31
  • 60
4
votes
1 answer

How to align HBox by using BorderPane alignment in FXML?

What am i trying is to align HBox Buttons to center in the Bottom in dialog box. I want to do this in fxml.However,BorderPane alignment is working in label. Here is code from my side.I think BorderPane.alignment="BOTTOM_CENTER" must work even if the…
Under_stand
  • 69
  • 1
  • 10
4
votes
2 answers

Localdate.format, format is not applied

I have a DatePicker in my FXML and I need the Date to insert it into my SQL-Database. I want to format my Date but it doesn't work. LocalDate localDate = purchased_at.getValue(); …
Vins
  • 291
  • 1
  • 5
  • 19
4
votes
5 answers

Checking dates if it is in a range

My Java FX app handles hours worked. I have work start and end time in 2 date fields. I succeeded in calculating the differences between 2 datesTime; but now how could I check if the result is in a night or day range???? The day begin at 6 and ends…
DJIBFX
  • 43
  • 6
4
votes
1 answer

JavaFX - MVC Application best practices with database

I'm new to JavaFX and I was wondering what are the best practices in this language to develop a MVC database application, I think my question will be pretty simple if you are an senior developer. Let us consider a simple example of a basic…
4
votes
1 answer

binding more than two property in fxml

Suppose I want to bind disable property of a button with a checkbox's selected property. I know this method to bind them in FXML:
Muzib
  • 2,412
  • 3
  • 21
  • 32