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

How to extend custom JavaFX components that use FXML

How do I properly extend a custom JavaFX component to add or modify its GUI components if it uses FXML for the view? As an example scenario, suppose I use the following approach of creating a custom JavaFX component: SpecializedButton.java…
15
votes
1 answer

JavaFX - How to get FXML Controller?

I have the following code: Parent parent = FXMLLoader.load(Main.class.getResource("JanelaPrincipal.fxml")); in the fxml file there is a reference to the controller class. How can I get the controller object? fxml:
ceklock
  • 6,143
  • 10
  • 56
  • 78
15
votes
1 answer

Binding a Label's text property (in an FXML file) to an IntegerProperty (in a controller)

I've set up a data binding between a Label in an FXML file and an IntegerProperty in the associated controller. The problem is that, while the label gets set to the correct value upon initialization, it is not updating when the property's value…
devuxer
  • 41,681
  • 47
  • 180
  • 292
15
votes
2 answers

javafx change css at runtime

Is it possible to change css for a JavaFX application while it is running? The effect I am looking for is changing skins or themes at the click of a button. The UI is in an FXML file if that makes any difference. I have…
Rob
  • 2,511
  • 2
  • 20
  • 31
15
votes
4 answers

fxml combobox, get the selected value into javafx

how can i catch the selected value of a fxml combobox and implement it into a javafx class? i gave the combobox the fx:id "sample" and created a button with onAction="#test" and tried .getValue and .getPromptText. @FXML private ComboBox
user2361460
  • 397
  • 2
  • 4
  • 9
14
votes
3 answers

JavaFX: Change application language on the run

I am making JavaFX desktop application with core components described in FXML and I would like to offer user the option to change the language. However I have not find any direct way how to change the language once the component has been loaded from…
Wolfer
  • 558
  • 2
  • 5
  • 21
14
votes
2 answers

ProGuard breaks JavaFX application

I'm trying to obfuscate my JavaFX application but it fails. The generated result does not work and I do not understand why. The resulting jar just fails because the fxml file cannot load all imports anymore (ClassNotFoundException). The Deployment…
Crine
  • 805
  • 7
  • 24
14
votes
6 answers

How to use font awesome in a fxml project (javafx)

I want to use font font awesome in my project but I have no idea how to use font awesome in my project. I had found some example but they can't be use in fxml. font awesome javafx I need help how to use it in my project using fxml Thank you.
user3749316
  • 182
  • 1
  • 1
  • 14
14
votes
3 answers

How to add a CSS stylesheet in FXML

I'd like to link a css file to my application. In my fxml file I use this: ...and I can see a styled preview when I open the fxml file in scenebuilder. But when I try to run…
cody
  • 6,389
  • 15
  • 52
  • 77
13
votes
2 answers

JavaFX access parent Controller class from FXML child

using JavaFX for an application and I have a Main.fxml file with some fxml child files inside it. I would like to access to MainController class of Main.fxml from the child Controllers. I'll try to explain better with an example: MainFxml:
piealoisi
  • 145
  • 1
  • 1
  • 6
13
votes
1 answer

JavaFX screen resolution scaling

I have been searching for a method to do this, but I only found This question without answers. I am developing in a 1366x768 laptop, I use JavaFX to create a GUI (I am sorry, but I can't post the code, it's basically an AnchorPane containing a…
Mayuso
  • 1,291
  • 4
  • 19
  • 41
13
votes
3 answers

JavaFX: Align Buttons inside ButtonBar (using SceneBuilder or fxml)

I have a JavaFX ButtonBar with two Buttons (created via SceneBuilder). I want one of the buttons to be left-aligned and the other right-aligned. (see screenshot) From the docs I already know how I could achieve this inside the…
drkthng
  • 6,651
  • 7
  • 33
  • 53
13
votes
1 answer

FXML, JavaFX 8, TableView: Make a delete button in each row and delete the row accordingly

I am working on a TableView (FXML) where I want to have all the rows accompanied with a delete button at the last column. Here's a video that shows what I mean: YouTube Delete Button in TableView Here's what I have in my main controller…
kmugi
  • 343
  • 1
  • 4
  • 13
13
votes
1 answer

JavaFX CSS Button with Image - How to define the size of the image?

I am trying to insert an image in a button using JavaFX CSS. Although, I can do it easily using the "-fx-graphic" tag, I cannot find a way to resize the image in whatever size I want. I can do this through the following FXML code, where I give 30 to…
javasuns
  • 1,061
  • 2
  • 11
  • 22
13
votes
3 answers

FXML Load exception

I got a problem that I absolutely can't solve on my own because I have just started using JAVA FX. I get a nasty javafx.fxml.LoadException: , but I have done exactly like a guide, but I cant get my Main to run. This is the the exception…
jabbeboy
  • 289
  • 2
  • 5
  • 14