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
9
votes
1 answer

JavaFX include fxml in fxml without controller

I'm programming an application with javafx. It's a "multiscreen" application with a mainmenu from where I can switch my scene. My scenes are defined in different fxml files. Because I try to use the mvc pattern I don't set the controller in the fxml…
Garog
  • 315
  • 1
  • 5
  • 15
9
votes
2 answers

Set CheckBoxTableCell in FXML

I currently have a problem with setting a CheckBoxTableCell from the FXML. I tried to convert this code to FXML: tableCol.setCellValueFactory(new PropertyValueFactory
bashoogzaad
  • 4,611
  • 8
  • 40
  • 65
9
votes
2 answers

JavaFX TextField CSS

How to create JavaFX TextField look like Android TextField using JavaFX CSS ? For example : I have tried lots of FX css but not achieved look like that . Here http://jsfiddle.net/QKm37/ CSS exist for HTML input type but it is not applicable in…
Gaurav Kumar
  • 323
  • 2
  • 4
  • 10
9
votes
2 answers

Should we use FXML in JavaFX custom controls or not?

It seems wired to ask this, I would think that using FXML to write our custom components is the obviously the right way to go. But as we can see from ControlsFX, JFXextras and even the book 'Mastering JavaFX8 controls do not use or mention the use…
David Limkys
  • 4,907
  • 5
  • 26
  • 38
9
votes
1 answer

How to implement language support for JavaFX in FXML documents?

How can I have different languages for a view in a FXML document to support many countries?
marc3l
  • 2,525
  • 7
  • 34
  • 62
9
votes
1 answer

Constants in an FXML file

Couldn't find any examples on this. How do I define constants in an FXML file? For example (where CONTENT_SPACING is the constant I want to create):
midrare
  • 2,371
  • 28
  • 48
9
votes
1 answer

Login Application with 1 stage and multiple scene in JavaFX

I am doing a timeline project. I have successfully created a login system and menus for everything, but when I press the buttons I have done so it will open a new window(with stage, scenes). I have read that it isn't the best approach. The best way…
jabbeboy
  • 289
  • 2
  • 5
  • 14
9
votes
1 answer

javafx automatic resizing and button padding

I'm trying to make an on screen keyboard with Javafx for the layout. I'm using the Scene Builder to make the FXML file.
Jeroen
  • 413
  • 1
  • 4
  • 16
9
votes
8 answers

Can not open FXML after a while

I have a problem with my JavaFX Scene Builder v2.0-b14. From time to time, the FXML can't get opened. Even if i remove everything from the FXML except the root. In the taskbar, it looks like this: If i rename the File, i can open the FXML…
Kalaschni
  • 2,301
  • 24
  • 37
9
votes
1 answer

javafx & fxml: how do I apply a border to a pane or label in my gui?

I'm just getting into using fxml and it seems like a really cool idea, except for the fact that I'm having a tough time getting it to work. Supposedly I'm able to lay out my GUI using a nice markup language, and I can style the elements via CSS. …
tadasajon
  • 14,276
  • 29
  • 92
  • 144
9
votes
2 answers

JavaFX : Adding a new node to Scene in java code when Scene is initially loaded from FXML

How can I add a new node to the Scene in java code when Scene is initially loaded from FXML ? I have loaded from FXML as shown below Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); Scene scene = new Scene(root, 1000, 600,…
thiru_k
  • 847
  • 2
  • 12
  • 21
9
votes
2 answers

JavaFX class controller scene reference

Is there any way of getting the Scene object of an FXML loaded file from the associated class controller. I'm doing something like this: @FXML private AnchorPane anchor; Scene scene = anchor.getScene(); but i'd like a solution that does not…
nailujed
  • 1,169
  • 5
  • 17
  • 23
9
votes
2 answers

JavaFX: Embedding encoded image in .FXML file

I would like to embed an encoded image into an FXML (i need this in that I'm coding a converter between svg and fxml). I tried with this:
Matteo Murgida
  • 161
  • 2
  • 7
8
votes
2 answers

How to listen for WindowEvent.WINDOW_SHOWN in the nodes of the scene graph?

It seems WindowEvent.WINDOW_SHOWN never gets dispatched on any of the nodes in the scene graph, nor is there anyway (that I could find) to know when a node is visible/rendered/shown. For example: TestLauncher.java package…
Andrey
  • 8,882
  • 10
  • 58
  • 82
8
votes
3 answers

Why JavaFX application and scene builder is showing garbled text?

Here's how my scene builder looks like: and here's the GUI: The standalone scene builder: I just run the following source code from Java SDK demos: package sample; import javafx.application.Application; import javafx.event.ActionEvent; import…
Stephane
  • 4,978
  • 9
  • 51
  • 86