fxml

MenuButton doesn't display items in Javafx

我与影子孤独终老i 提交于 2019-11-29 15:57:25
I have a class Foo which just load the FXML and create the scene. In the FXML, I set the controller to be FooController ( fx:controller="FooController" ) And I add a MenuButton: <MenuButton fx:id="menuButton" layoutX="264.1875" layoutY="146.5" mnemonicParsing="false" text="MenuButton" /> And I try to set the menuButton in the FooController: public class FooController implements Initializable{ @FXML final MenuButton menuButton = new MenuButton("Modalities"); @Override public void initialize(URL arg0, ResourceBundle arg1) { final ObservableList<CheckMenuItem> listFilter = FXCollections

How can I right click on a cell in tableview in Javafx (fxml)?

☆樱花仙子☆ 提交于 2019-11-29 15:19:55
I am programming a table view with JavaFX and fxml. I want to do some actions when a user right clicks on a cell in the table. How can I do that? Is it possible to create a right click menu over a cell? Thanks! Implement a cell factory for the table column(s) of interest. Create a cell in the cell factory and register the mouse listener with the cell. Referring to the standard table example you can do something like firstNameCol.setCellFactory(new Callback<TableColumn<Person, String>, TableCell<Person, String>>() { @Override public TableCell<Person, String> call(TableColumn<Person, String> col

What is wrong with my syntax calling a stylesheet (css) from an FXML file?

雨燕双飞 提交于 2019-11-29 14:46:05
I am working in NetBeans 8, with Java 8 / JavaFX and FXML. In the first controller (an AnchorPane) in my FXML document, I have this, that works: stylesheets="file:///C:/Users/me/Documents/NetBeansProjects/MyApp/src/myApp/myStyle.css" However, when I attempt to replace that with any type of relative path, I get the following error at runtime: com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged WARNING: Resource "myStyle.css" not found. I tried stylesheets="myStyle.css" stylesheets="file://myStyle.css" stylesheets="./myStyle.css" stylesheets="css/myStyle.css" (where I put a copy of the

Static @FXML variables in FXML Controller

吃可爱长大的小学妹 提交于 2019-11-29 12:55:45
I upgraded from javafx 8 b109 to b116 and my FXML controller class has the injected variables as null when it initializes. I tried it with the sample netbeans fxml app. @FXML private static Label label; @Override public void initialize(URL url, ResourceBundle rb) { label.setText("static test"); } The problem is with the static keyword, remove that and it works. It was working fine in b109 with static variables. When writing my app initially, I figured static made sense. They're created when the application loads and there's only ever one copy of the scene. Is there a way around this without

Changing the text of a label from a different class in JavaFX

心不动则不痛 提交于 2019-11-29 12:37:59
This question was already asked here but was not able to find any answers. I have reproduced a similar situation where I would like to change the text of a label from another class using the controller FXMLDocumentController.java public class FXMLDocumentController implements Initializable { @FXML private Label label; @FXML private void handleButtonAction(ActionEvent event) { System.out.println("FXMLDocumentController.#handleButtonAction"); label.setText("Hello World!"); Connector.Connecting(); } @Override public void initialize(URL url, ResourceBundle rb) { // TODO } public void setLabelText

create array of Label using FXML in JavaFX

主宰稳场 提交于 2019-11-29 12:15:20
Actually, I want to create a navigation list using Labels in Javafx. I can assign fx:id to each label and create labels in controller class. But what I want to do is, instead of ten Label objects in controller class, I want an array of Labels in controller class, which I created in scene builder. Can somebody help me figure out a way... Some things are just better done in Java than FXML. I would not create the labels in FXML at all in this scenario; just create the pane that is going to hold them, then create the labels in the controller and add them to the pane. That said, it can be done the

FXML / FXMLLoader error diagnostic tool(s) sought

送分小仙女□ 提交于 2019-11-29 11:21:42
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 Preview option. I have a ' simple .fxml' file I use to verify that the controller is working as intended, that is same controls and events but without the extra FXML layouts. And I have and I am doing the cut-out-code and test loop to identify the XML with the problem. So I will get to the bottom of this at some point. At present there are no errors

JavaFX 2.0 + FXML. Updating scene values from a different Task

随声附和 提交于 2019-11-29 11:14:01
I want to get the controller from a scene that i've loaded with FXMLoader. The use case is: My JSON manager receives a JSON object The task I've launched shows a new Scene using Parent p = FXMLLoader.load(getClass().getResource("foo.fxml")); Scene scene = new Scene(p); stage.setScene(scene); After that, i have the empty scene. Now I do this to fill the components AnchorPane pane = (AnchorPane)((AnchorPane) scene.getRoot()).getChildren().get(0); for(Node node : pane.getChildren()){ String id = node.getId(); if(id.equals(NAME)){ ((TextField)node).setText(value); } } My question, is there an

How to load content to JavaFX tabs dynamically?

那年仲夏 提交于 2019-11-29 10:41:00
问题 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 (and described with a lot of nodes). The set of cities contains 30 elements. When the GUI is launched, it asks the server for a list of the cities. The server returns a random "sub-set" of cities (so, it can be Moscow + Riga + New York or St

Unable to get Scene from MenuItem in JavaFX

元气小坏坏 提交于 2019-11-29 09:59:09
I am trying to change the scene in a javafx stage based on menuItem click. Here is my sample.fxml: <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.net.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.*?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.GridPane?> <AnchorPane prefHeight="-1.0" prefWidth="560.0" styleClass="background" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="sample