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

ComboBox FXML default value

How can I set a default value in a ComboBox using FXML?
Perneel
  • 3,317
  • 7
  • 45
  • 66
19
votes
2 answers

How to position a button (or any GUI element) in a JavaFX scene?

I am trying to put a JavaFX button in a specific place (specific coordinates) on a UI, but nothing is working. I'm guessing that there is a method that is used for this, but I can't find it.
Milos Maksimovic
  • 299
  • 2
  • 5
  • 17
18
votes
7 answers

RequestFocus in TextField doesn't work

I use JavaFX 2.1 and I created GUI using FXML, in the controller of this GUI I added myTextField.requestFocus();. But I always get the focus in the other control.
Adil
  • 4,503
  • 10
  • 46
  • 63
18
votes
3 answers

Getting started on Scala + JavaFX desktop application development

Is there some guide or walkthrough to building a Scala + JavaFX desktop application? I'm having hard time finding a good source and I am using IntelliJ IDEA as the IDE. Even the most simplistic desktop hello world samples would help a lot, because I…
Tower
  • 98,741
  • 129
  • 357
  • 507
18
votes
3 answers

How to reference primaryStage

I use .fxml-Files for the view-layer of my application. Each fxml has a controller attached to it Let's assume I have a mainFrame and it's controller. The mainFrame.fxml is…
Gundon
  • 2,081
  • 6
  • 28
  • 46
18
votes
3 answers

How to bind stage resizing with resizing of components?

I have a JavaFX 2.0 application with FXML. I want the components (TextFields, ComboBoxes, layouts, and so on) to be resized when a window with an application is resized. So... As it is written on Oracle documentation for JavaFX, to make something…
Victoria Agafonova
  • 2,048
  • 10
  • 33
  • 50
17
votes
2 answers

Adding RadioMenuItem to ToggleGroup in FXML

Somewhere inside my FXML, I have this:
spilot
  • 625
  • 1
  • 7
  • 20
17
votes
3 answers

How to load fxml file inside Pane?

If we have a Stage then Scene includes 2 Panes the 1st Pane contains Button and the 2nd Pane is empty could we load other fxml file inside this 2nd Pane? fxml1: VBox |_Pane1-->Button |_Pane2 /////////////// fxml2:…
Hussein Ahmed
  • 730
  • 2
  • 7
  • 17
17
votes
3 answers

JavaFX & FXML: how do I set the default selected item in a ChoiceBox in FXML?

I have the following FXML:
tadasajon
  • 14,276
  • 29
  • 92
  • 144
16
votes
2 answers

How to connect FX controller with main app

I have a main app class and a fxmlController class but I am entangled in connecting/organizing(confused how these are called and how I should organize them to make the GUI connected business logic) business logic and GUI. Can someone please tell the…
khan
  • 185
  • 1
  • 2
  • 8
16
votes
7 answers

How to make canvas Resizable in javaFX?

In javaFX to resize a canvas there is no such method to do that, the only solution is to extends from Canvas. class ResizableCanvas extends Canvas { public ResizableCanvas() { // Redraw canvas when size changes. …
HinoHara
  • 572
  • 3
  • 13
  • 24
16
votes
2 answers

JavaFX tableview resize to fit window

I am just trying out JavaFX and am forcing my way into it because it is suppose to be the future. I am trying to create a table with 4 columns. The columns AND THE TABLE should resize to fill the parent pane. I cannot for the life of me get this…
bzanchi
  • 163
  • 1
  • 1
  • 5
16
votes
2 answers

How do I access a UI element from another controller class in JavaFX?

I have a JavaFX / Java 8 application written with NetBeans 8 (no SceneBuilder). My application has a main window that has its own FXML file (primary.fxml) and its own controller class (FXMLPrimaryController.java). One of the items in the FXML is a…
adeena
  • 4,027
  • 15
  • 40
  • 52
16
votes
3 answers

JavaFX IllegalAccessException during FXML load()

I have a dialog window that is invoked by the following code (DialogController is a helper class for using modal dialog windows; it mainly bundles together a controller reference with its window): void handleServicesEdit(ActionEvent event) throws…
scottb
  • 9,908
  • 3
  • 40
  • 56
15
votes
2 answers

How to pass object created in FXML Controller1 to Controller2 of inner FXML control

I have a JavaFX 2.0 application, which consists of two FXML files, and two controllers for them + one "main" .java file. At the start time, FXML1 is initialized, like this: public void start(Stage stage) throws Exception { stage.setTitle("Demo…
Victoria Agafonova
  • 2,048
  • 10
  • 33
  • 50