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
13
votes
2 answers

What are JavaFX, FXML and Scene Builder?

I am new to JavaFX, and am trying to do a project in it. In some tutorials they mention FXML. What is the difference between the two? I am using NetBeans IDE to develop my project, and heard about using Scene Builder when working with FXML. What…
TomJ
  • 1,803
  • 14
  • 37
  • 57
13
votes
2 answers

expand a GridPane to max width and height

is it possible to expand a grid pane to max width and height? i have the following:
user1090694
  • 609
  • 4
  • 8
  • 16
12
votes
2 answers

JavaFX: Best practice for navigating between UI screens

I want to change UI screens from login.fxml to home.fxml. Should I change the Stage or the Scene? I'm not sure which is the best practice? Also, can I use a lambda expression for the handler in the controller?
user4016255
12
votes
1 answer

how do I get an element in JavaFx using an id?

I am new to FXML and I am trying to create a handler for all of the button clicks using a switch. However, in order to do so, I need to get the elements using and id. I have tried the following but for some reason (maybe because I am doing it in the…
Rakim
  • 1,087
  • 9
  • 21
  • 40
12
votes
4 answers

Communication between two JavaFx controllers

I made a structure to of Controllers and Views (fxml) to separate my code as much as I could, and I'm wondering how to communicate between 2 controllers. I mean, a controller have to call some functions of another controller to set it up to date. I…
jbrtrnd
  • 3,815
  • 5
  • 23
  • 41
12
votes
4 answers

Unable to get Scene from MenuItem in JavaFX

I am trying to change the scene in a javafx stage based on menuItem click. Here is my sample.fxml:
rahulserver
  • 10,411
  • 24
  • 90
  • 164
12
votes
1 answer

How to do binding in FXML, in JavaFX 2?

Oracle docs aren't very clear on this, google and bing neither. Can I (like in WPF) bind to a model in FXML skipping the binding code in Java? I did see, for a brief flash, a syntax like ${object.field} on a blog somewhere but I can't be…
Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166
12
votes
2 answers

To Hide JavaFx fxml or JavaFx swing application to System Tray

I want to develop a client app for website . I want the app to reside in system tray when minimised. I dont know how to accomplish this task . Is their any example for this type of operation.
Mohammad Sadiq Shaikh
  • 3,160
  • 9
  • 35
  • 54
11
votes
3 answers

What is a "Node" in JavaFx/FXML?

What is meant by the word "Node" within context of JavaFx/FXML? If I search for this question, all I find are people using the term discussing something else, but no explanation. For example, this answer to the question: How do I open the JavaFX…
Sargon1
  • 854
  • 5
  • 17
  • 48
11
votes
3 answers

how to locate fxml from another package?

I have created a simple JavaFX application. It has two packages the main class is JFXTest2.java is in good package and the fxml and it's controller are in JFXTest2 package. now the problem is that i can not load the fxml in the main class. I tried…
Gandalf
  • 2,921
  • 5
  • 31
  • 44
11
votes
8 answers

How to limit the amount of characters a javafx textfield

I´m using a FXML to set my form, but I need to set the limit of characters in textfields. How can I made this ?
Bran Stark
  • 369
  • 3
  • 5
  • 15
11
votes
3 answers

How to use FXMLLoader.load() - JavaFX 2

I am building a JavaFX application using the JavaFX Scene Builder. The interface was created in the Scene Builder and a FXML file (main.fxml) was created. To use the interface in my application I must load the FXML file using the FXMLLoader, but…
ceklock
  • 6,143
  • 10
  • 56
  • 78
11
votes
5 answers

JavaFX style class won't refresh

I'm adding a style class to an node if it's selected and then remove it if I select other item. Even if I remove the style class the style wont refresh so it wont go back to normal…
user1236048
  • 5,542
  • 7
  • 50
  • 87
10
votes
3 answers

Using JavaFX controller without FXML

Is there a possibility to use a controller with a JavaFX GUI without using FXML. I noticed that the FXML file contains an fx-controller attribute to bind the controller but i don't find it an easy way to work with it. Any ideas about have an MVC…
Hassam Abdelillah
  • 2,246
  • 3
  • 16
  • 37
10
votes
2 answers

How to access a JavaFx Stage from a Controller?

I'm converting a pure JavaFx app, in which the code below worked fine when put all in one class, to a FXML one, where the Stage declaration and the button handler are in separate classes. In the a Controller, I'm trying to implement a method that…
Sargon1
  • 854
  • 5
  • 17
  • 48