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
37
votes
3 answers

Customize ListView in JavaFX with FXML

I want to make a customize list view in javafx. Here I need to bind multiple component in list cell as follow, like one label, one textfield, one button under one HBox and two button, one hyperlink, one label in another HBox and these HBox comes…
Santosh Biswakarma
  • 410
  • 1
  • 5
  • 7
36
votes
2 answers

FXML full reference?

I'm trying to learn JavaFX 2.0 + FXML, and i found it kind of uncomfortable to make fxml file, without knowing what i can put in it and what i can't. I mean which tags are possible in FXML, which attributes evety tag has? which values evety…
Victoria Agafonova
  • 2,048
  • 10
  • 33
  • 50
35
votes
8 answers

How to control the JavaFX Tooltip's delay?

I was playing around with JavaFX's Tooltip. I realized that for me personally the delay between hovering over something and the tooltip actually appearing is too long. A look in the API reveals: Typically, the tooltip is "activated" when the mouse…
Turing85
  • 18,217
  • 7
  • 33
  • 58
34
votes
7 answers

Why would scenebuilder 2.0 fail to open my fxml file?

I have an fxml file that I created using SceneBuilder 2.0. This file is used in my JavaFx project that I am developing using Netbeans 8. Today, SceneBuilder stopped working with my file. When I tried to open it, SceneBuilder would minimize and would…
Justin Wiseman
  • 780
  • 1
  • 8
  • 27
33
votes
8 answers

How to switch scenes in JavaFX

I have looked on many pages to try and find out how to switch scenes but I have been unsuccessful. I have a calculator and my goal is to select a menu option to change Calculators(ie: basic and scientific). Right now I am just testing so here is my…
Megan
  • 474
  • 1
  • 5
  • 11
31
votes
5 answers

How to get selected radio button from ToggleGroup

I an working on JavaFX 8 and SceneBuilder. I created some radio buttons in the FXML File and specified a toggleGroup name to a radio button list in that. So, now I want to get the toggleGroup's selected radio button in my controller, do I need to…
rjalfa
  • 729
  • 1
  • 8
  • 14
31
votes
1 answer

JavaFX Project Structure

JavaFX's MVC Model by using FXML sounds awesome and all but I'm having trouble find out how to organize my project packages. Every single tutorial i find about JavaFX is way too simple and unorganized: They simply create ONE package and create…
Xkynar
  • 935
  • 1
  • 10
  • 31
31
votes
2 answers

How do I add margin to a JavaFX element using CSS?

I have the following fragment of FXML:
vbezhenar
  • 11,148
  • 9
  • 49
  • 63
31
votes
3 answers

Styling a JavaFX 2 button using FXML only - How to add an image to a button?

I want to change the styling of a button, most of the threads here and the articles on the internet show how to do it using Java code, which I don't see it as a real good solution, is there any way for example to set a button with some text and an…
AymenDaoudi
  • 7,811
  • 9
  • 52
  • 84
30
votes
4 answers

How to create multiple javafx controllers with different fxml files?

I've been looking at some blogs and other stackoverflow questions, and I'm not seeing a direct answer to my question. I am creating a javafx gui client and I want to have my menubar be one controller in one fxml and then i want the content area to…
j will
  • 3,747
  • 11
  • 41
  • 64
29
votes
6 answers

JavaFX: FXML: How to make the child to extend its size to fit the parent pane?

I have managed to load a child fxml(sub UI) under a parent fxml (mainMenu UI). I have created an AnchorPane with id "mainContent". This pane is bound to 4 sides and changes in accords to the stage. The child window will be loaded into the…
Dean Chiu
  • 1,325
  • 1
  • 13
  • 13
29
votes
2 answers

JavaFX Nested Controllers (FXML )

In this tutorial, there is an example of how to include custom components and use their controllers from the controller of the container. main_window_content.fxml
Antonello
  • 321
  • 1
  • 3
  • 5
29
votes
2 answers

Multiple FXML with Controllers, share object

Goodevening everyone, I have found a bunch of posts already on this topic but I still can not manage to pass an object from Controller1 to Controller2. Is there somewhere a full tutorial or some example project that does this? I've gotten this far…
Perneel
  • 3,317
  • 7
  • 45
  • 66
28
votes
3 answers

How to initialize JavaFX controllers with the same model object?

Scenario I am creating a GUI where multiple views reference the same model object. What I am Accustom to In Swing, if i want all the views to reference the same model i would pass the model into the constructor. What I am Currently Doing In…
j will
  • 3,747
  • 11
  • 41
  • 64
27
votes
2 answers

How to embed .ttf fonts in JavaFx 2.2?

Firstly, I am quite a new guy in coding. I need to embed a font in my java FXML-based app and don't know how to do it. I have pasted the font, fontName.ttf in a "resources" folder in the root of the sources of my project, ie App/src/app/resources. I…
Pratik Anand
  • 795
  • 5
  • 10
  • 19