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

JavaFX java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field sample.Controller.location to java.net.URL

My JavaFX application has a Label with an fx:id of location. It is defined in an FXML file. When I try to run the application, I get the following error: java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field…
Barry Brown
  • 20,233
  • 15
  • 69
  • 105
8
votes
1 answer

FXML Label text bold

Can someone please tell me how to make the text inside a label bold in Java FXML?
Delin Mathew
  • 249
  • 3
  • 6
  • 15
8
votes
0 answers

JavaFX purpose of xmlns:fx

This Java tutorial by Oracle says that The xmlns:fx attribute is always required and specifies the fx namespace. but what exactly is the fx namespace? And what values qualify for this attribute?
xeruf
  • 2,602
  • 1
  • 25
  • 48
8
votes
1 answer

How to enable a dropdown list of predetermined items to add to a custom control in SceneBuilder?

The DialogPane has this implementation in SceneBuilder: You can add to the Pane a list of buttons. I am looking to do this for my custom control in scenebuilder. I could not find anything obvious inside the constructor for DialogPane that would…
jpell
  • 163
  • 1
  • 10
8
votes
2 answers

FXML control always null when using Kotlin

Using IntelliJ I created a JavaFX application and then added Kotlin and Maven as frameworks to it. It came with a sample.fxml file and a Controller.java and Main.java. I created a new class for the controller in Kotlin (MainWindowController.kt) and…
GregInWI2
  • 904
  • 1
  • 17
  • 26
8
votes
1 answer

How can I add a tooltip to a node that does not implement Control using FXML?

In JavaFX subclasses of Control have a tooltip property which means that one can declaratively add a Tooltip using FXML thusly:
brcolow
  • 1,042
  • 2
  • 11
  • 33
8
votes
2 answers

Create FileChooser in FXML

I'm trying to create a fileChooser within an fxml file. My code looks like this:
8
votes
1 answer

Javafx fxml file TextArea line break and tab in text

How to edit text in the TextArea in `.fxml file as such I can use line breaks and tabs. The Textarea is predefined and can not be edited. Images to support FXML File The View
Sevi
  • 605
  • 1
  • 6
  • 13
8
votes
1 answer

FXML scene builder invalid attribute after filling ComboBox

I have this FXML file, where I tried to populate the ComboBox:
Mansueli
  • 6,223
  • 8
  • 33
  • 57
8
votes
1 answer

How to attach a CSS stylesheet to FXML?

Following Oracle tutorial http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm, I create FXML with a fragment
user3603546
  • 325
  • 2
  • 11
8
votes
2 answers

With a running JavaFX application, open a new window with its own, separate controller class

I'm using SceneBuilder in conjunction with Netbeans' JavaFX library for this project. I use Scenebuilder to create the fxml and netbeans for the controller classes. The goal is to build a fairly complex app that is to be deployed. I can launch a…
Kyte
  • 834
  • 2
  • 12
  • 27
8
votes
2 answers

Using FXML to Create ContextMenu within a Pane

I've got a working example for defining a ContextMenu on a Pane in JavaFX FXML, but am not sure it is optimal. Currently, only JavaFX standard controls (e.g. Button, TextField) define a property for specifying a popup ContextMenu. Yet I wanted to…
NaderNader
  • 1,038
  • 1
  • 11
  • 16
8
votes
1 answer

How to load content to JavaFX tabs dynamically?

I have a GUI, made using JavaFX with FXML. This GUI has a lot of components and not all of them are needed at one moment of time. For example, imagine a GUI that receives from its server part a list of cities. Each city is described on its own tab…
Victoria Agafonova
  • 2,048
  • 10
  • 33
  • 50
7
votes
1 answer

How to set several default CSS stylesheet for an application with JavaFX 9 (a replace for StyleManager)?

Whose damn idea it was to exclude StyleManager without direct and clear replacement - it broke many programs as I see! I need to make some restyling for the whole application (custom components, custom pseudo classes, custom platform-specific…
Sap
  • 914
  • 1
  • 6
  • 20
7
votes
3 answers

How can I prevent a window from being too small in JavaFX?

I have this very simple form and I set the min width and height of all UI controls to be USE_PREF_SIZE, so, they cannot get too small: The code looks like this:
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622