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

FXML and Controller in different packages - Button onAction issue

I'm new to JavaFX and currently having some trouble working with onAction events with classes within different packages. Here is the package tree : Here is the sample of code that is not working :
Xema
  • 1,796
  • 1
  • 19
  • 28
4
votes
1 answer

How to center scaled vector graphic on Button?

I want to draw scaled SVGPath nodes centered on button. Button should maintain its size independent of image size, and SVGPaths should retain their relative positions. I am new to JavaFX so maybe I'm taking the wrong approach. Basically I'm trying…
krsi
  • 1,045
  • 2
  • 14
  • 24
4
votes
2 answers

Why I'm getting javafx.fxml.LoadException even the path of the fxml file is correct

I get javafx.fxml.LoadException: When I'm loading and fxml file using following line of code. AnchorPane anchorPane = (AnchorPane)loader.load() This is my fxml file excluding import statements.
4
votes
2 answers

FXML document naming convention

Is there a specific document naming convention I should follow when creating FXML files or XML files in general? I've been following some tutorials that Oracle has provided and come to the conclusion that FXML files should start with the…
Pavan P
  • 645
  • 8
  • 17
4
votes
1 answer

JavaFX 8: The keyboard events are not being processed if a scene has only shapes

It seems there is an issue in setting focus (and handling keyboard events) on the JavaFX scenes that have only shapes (e.g. Rectangle, Circle, etc). Since formatting FXML is not easy at stackoverflow, I described the issue and a workaround in my…
Yakov Fain
  • 11,972
  • 5
  • 33
  • 38
4
votes
2 answers

JavaFX FXML: Cannot bind to static property

I am trying to create a JavaFX app for multiple screen resolutions (also high resolutions). I want to use variables/calculations in my FXML file (JavaFX project). This works when I only do the calculations in prefWidth, prefHeight etc only. When…
Tijme
  • 39
  • 2
  • 24
  • 41
4
votes
1 answer

Redirect Console Output to JavaFX TextArea?

I want to show the console output in a JavaFX TextArea... unfortunately I cannot find any working example for JavaFX but only for Java Swing, which not seems to work in my case. EDIT: I tried to follow this example:…
Airlike
  • 233
  • 2
  • 6
  • 14
4
votes
4 answers

Selecting multiple items from combobox

Pls i want to know how to change the selectionmodel of javafxml combobox so that it can allow multiple seletion. Any contribution will be appreciated thanks.
Odum
  • 49
  • 1
  • 1
  • 3
4
votes
1 answer

set the content of an anchorPane with fxml file

I use the accordion control. Depending on the titled pane, I need to load a fxml file into an anchorPane. So I have two parts: one for accordion and another one for anchorPane to display contents depending on click. @FXML private StackPane…
Hayat Bellafkih
  • 587
  • 2
  • 11
  • 28
4
votes
1 answer

Rotating image animation in fxml

I am having a custom image, i just need to rotate the image while loading the respective page instead of default indeterminate progress indicator symbol. Do we have any css code to rotate the image continuously. please guide me.
Karthikram
  • 105
  • 3
  • 9
4
votes
3 answers

FXML cellValueFactory for TreeTableColumn

I've been trying to build a Tree Table and define the cellValueFactories in FXML. When I try this, I get the following error in the stack trace Exception in thread "JavaFX Application Thread" java.lang.ClassCastException:…
LinkXXI
  • 314
  • 2
  • 13
4
votes
1 answer

How to pass a Variable through JavaFX Application to the Controller?

I'd like to ask if it is possible to pass a Variable through a JavaFX Class what extends Application to my JavaFx Controller? I am very new to JavaFx and only may need a little kick. The goal is to pass a Id from MyClass to MyController. My…
Artur Rem
  • 209
  • 1
  • 4
  • 18
4
votes
2 answers

FXML / FXMLLoader error diagnostic tool(s) sought

overview Hi, here's an outline use-case. I have a seemingly valid FXML file developed in JavaFX Scene Builder. It is by now a non-trivial chunk of XML and there are runtime load errors somewhere in the FXML file. Scene Builder works fine with the…
will
  • 4,799
  • 8
  • 54
  • 90
4
votes
1 answer

get FXML file nodes using java code

How to get elements or nodes from FXML file using Java, I know the way by using initialization or by setting controller class in FxmL . But I need to do it without any controller. I want to access the nodes inside the fxml file using. My FXML…
GowthamIyer
  • 485
  • 1
  • 5
  • 17
4
votes
2 answers

label.setText NullPointerException

Hi first time here but here goes: I have a JavaFX application that changes the FXML UI labels dynamically and the data is pulled from a Player class. The two classes in question are Player.java and InterfaceHandler.java. The player class stores…
twin_suns
  • 43
  • 1
  • 1
  • 4