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
26
votes
5 answers

How to handle ListView item clicked action?

I have my JavaFX 2.0 application, where i need to make some action, after user clicked an item in ListView element. To construct user GUI i'm using FXML, in which i have something like this:
Victoria Agafonova
  • 2,048
  • 10
  • 33
  • 50
26
votes
1 answer

How to get parent Window in FXML Controller?

For example, I want open a DirectoryChooser when clicking on the button:
nvcnvn
  • 4,991
  • 8
  • 49
  • 77
24
votes
2 answers

Javafx open another fxml in the another window with button

Is it possible in javafx to open new stages (windows) from another fxml with a button? Thanks for the answers.
Sevi
  • 605
  • 1
  • 6
  • 13
24
votes
2 answers

FXMLLoader getController returns NULL?

I have the main application class that does the following just fine: @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource( "RecordScreen.fxml")); …
Toni_Entranced
  • 969
  • 2
  • 12
  • 29
23
votes
1 answer

What is the "mnemonicParsing" attribute in Java FX

I have been working with SceneBuilder and I observe that it applies the attribute of mnemonicParsing and equates it to false for every Node that I make. What exactly is it? What difference does it make in Layout.xml?
Tilak Madichetti
  • 4,110
  • 5
  • 34
  • 52
22
votes
3 answers

Is @FXML needed for every declaration?

Is @FXML needed for every declaration or just for the first? In other words, should I use @FXML public Label timerLabel = new Label(); @FXML public TextField mainTextField, projectTextField ; @FXML public Button goButton, deleteAllButton…
Romeo
  • 311
  • 1
  • 2
  • 9
22
votes
1 answer

Java FX fxml on Action

I want to add a method to a button which is defined in my Controller class in the console is only an error which tells me that it couldn't find the method here is the code sample.fxml
Jhon Smith
  • 347
  • 2
  • 3
  • 9
21
votes
4 answers

Bootstrap with JavaFX

I am creating a GUI in a java fxml project using netbeans. I wanted to use bootstrap to style the gui but I have noticed that everything in javafx is prefixed with fx-. Is there still a way to get bootstrap to work anyway for my project? Does…
jamespick
  • 1,974
  • 3
  • 23
  • 45
21
votes
6 answers

Default JavaFX-CSS

Is there any way to see the applied CSS-Rules for JavaFX-Elements? Or there is a published reference with the default CSS-Rules available? I would like, for example , to know the color of Toolbar's border.
Gundon
  • 2,081
  • 6
  • 28
  • 46
20
votes
2 answers

JavaFX 8 - Tabpanes and tabs with separate FXML and controllers for each tab

I hope to get some answers regarding having fx:include statements for each tab in a tabpane. I have managed with ease to get content to show up BUT referencing methods of the associated controller class simply gives me a nullpointerreference…
Måns Thörnvik
  • 1,038
  • 2
  • 10
  • 22
20
votes
1 answer

JavaFX How to set max/min window size?

Does setMinSize() work on containers such as GridPane, for example? I have found that in my program GridPane ignores min. size properties while resized manually. Here is the FXML code:
Chechulin
  • 2,426
  • 7
  • 28
  • 35
20
votes
2 answers

How to change sub fxml gui parts at runtime with Button Click

I'm tryin to build a skeleton for a big complex gui, so the idea is to make everything with mvc like style in javafx 2.1, so every component has a fxml file and if needed css,controller and model. I'm tryin to figure out how to change sub scenes(sub…
Snow
  • 223
  • 1
  • 2
  • 7
19
votes
1 answer

Set multiple styleClass values

How does one set two classes on a node in a JavaFX FXML file? This adds one value "notice high" instead of two values "notice" and "high". How can I add two values?
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
19
votes
7 answers

How can I show an image using the ImageView component in javafx and fxml?

I suppose it's a very simple thing but I just can't get behind it. All I want is to show an image over an ImageView linked to fxml. Here is my code: package application; import java.io.File; import javafx.application.Application; import…
user3472050
  • 191
  • 1
  • 1
  • 5
19
votes
8 answers

Can I automatically generate controller classes from FXML?

As I understand it, when using FXML to describe a Java FX scene, the controller class is written manually and it's member variables and methods can then be referenced from the .fxml file. When loading the scene using the FXMLLoader, member variables…
Feuermurmel
  • 9,490
  • 10
  • 60
  • 90