fxml

Save JavaFX scene into FXML file

孤街浪徒 提交于 2020-01-21 12:53:18
问题 Anyone knows how to save a JavaFX scene into FXML file that can be loaded by the JavaFX FXMLLoader? The SceneBuilder allows to do it, but if I build the scene manually, how I can save it into FXML file? 回答1: If you mean build a fxml file from a running screen built in Java, the short answer is that you can't. The fxmlLoader is designed to work only to load files, it references the class XMLInputFactory but not the XMLOutputFactory. If you would like to do it by yourself, it is not only

FXML, Alternate Uses: Using ObservableList<>

坚强是说给别人听的谎言 提交于 2020-01-16 11:26:15
问题 As in this thread FXML: Alternate Uses, I am building an application that uses FXML for loading objects into memory directly. I have successfully setup objects where specific properties can be easily set like hostName , typeName , moto , e.g. But, in FXML you have lists - like child nodes of JavaFX UI elements held in a ObservableList . I am having trouble using a features ( ObservableList ) property in FXML. It gives an error that UnsupportedOperationException: cannot determine type for

Use progressbar made with fxml (scenebuilder) to use values from a method [duplicate]

混江龙づ霸主 提交于 2020-01-15 10:37:06
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . I want my progressbar to display the values of a method thats returns double values but it doesnt work. But I dont think thats the main problem bc even when I just use a specific number it doesnt work either. Please help me, thanks in advance. That's specific question so I searched cery long without results so if you know a better to do what I want to do or maybe

Drawing a Region with CSS -fx-shape. How it is possible?

久未见 提交于 2020-01-14 10:37:29
问题 I'm looking a way to draw shapes in a Region (JavaFX8) I've seen some examples that set the region style like this: -fx-shape : "M 3.0313 0 L 0 74 L 7.9688 74 L 4.9375 0 L 3.0313 0 Z"; Can anyone give an explanation of the meaning of this string? Is there any way to create this type of string using Visual Software? 回答1: The shape string is an SVG Path. Note the shape string for a region is the shape of the region, not a shape in a region. If you want to create shapes based on paths to put in

how do I get an element in JavaFx using an id?

醉酒当歌 提交于 2020-01-13 09:17:08
问题 I am new to FXML and I am trying to create a handler for all of the button clicks using a switch . However, in order to do so, I need to get the elements using and id. I have tried the following but for some reason (maybe because I am doing it in the controller class and not on the main) I get a stack overflow exception. public class ViewController { public Button exitBtn; public ViewController() throws IOException { Parent root = FXMLLoader.load(getClass().getResource("mainWindow.fxml"));

How to initialize JavaFX controllers with the same model object?

三世轮回 提交于 2020-01-11 15:48:10
问题 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 JavaFX, I am passing the model around by having a setter method in the views/controllers (menubars, split panes, tabs, ...), after each view/controller has been loaded. I find this very tacky and cumbersome. Additionally, I find it won't work because in

How to trigger an event on focus out for a textfield in javafx using fxml?

风流意气都作罢 提交于 2020-01-11 11:56:11
问题 I have this function in the controller class of the relevant fxml. I need this function to be fired on focus out from a textfield, but scene builder doesn't have an event similar to onfocusout. How to achieve this using the control class? @FXML private void ValidateBikeNo(){ Tooltip error = new Tooltip("This bike no exists"); BikeNoIn.setTooltip(error); } 回答1: You can attach a focusListener to the TextField and then execute the code inside it. The listener can be attached inside the

Bind width and height of dynamically loaded fxml

给你一囗甜甜゛ 提交于 2020-01-11 11:39:07
问题 At the moment I have an issue with dynamically loaded FXML files during runtime. Once they are added to a Pane, they do not resize to use the full widht & height of that pane. I use this method to load a FXML in my Pane: public void showContentPane(String sURL){ //1. sURL can be something like "/GUI/home/master/MasterHome.fxml" //2. getContentPane() returns following object: Pane pContent try { URL url = getClass().getResource(sURL); getContentPane().getChildren().clear(); Node n = (Node)

JavaFx fx:id causes error

 ̄綄美尐妖づ 提交于 2020-01-11 11:38:12
问题 For some reason, my fx:id does not bind properly to my Controller class, and thus always causes an error. Controller package sample; import javafx.fxml.FXML; import java.awt.*; import java.awt.event.ActionEvent; public class Controller { @FXML public Button button; public void clickAction(ActionEvent actionEvent) { System.out.println("Button clicked."); } } FXML <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <BorderPane fx:controller=

NullPointer Exception on setText() while everything is properly loaded and annotated

我的梦境 提交于 2020-01-11 09:52:13
问题 I'm receiving the following exception trying to call setText() on my annotated label, from the start() method. I've seen a similar question, but the reason why it didn't work for that person is because his label isn't annotated, while mine is. java.lang.NullPointerException at io.github.blubdalegend.openbravery.OpenBravery.applyBuild(OpenBravery.java:67) at io.github.blubdalegend.openbravery.OpenBravery.start(OpenBravery.java:58) at com.sun.javafx.application.LauncherImpl.lambda