fxml

Controller returning null in javafx helloworld

时间秒杀一切 提交于 2019-12-24 13:18:40
问题 So of course I dive straight in to creating a simple example. public class Main extends Application { URL bla = getClass().getResource("/sample.fxml"); @Override public void start(Stage primaryStage) throws Exception{ //If you get weird errors: http://zenjava.com/javafx/maven/fix-classpath.html //but not actually my issue. Example displays fine in intellij. try { FXMLLoader loader = new FXMLLoader(bla); Parent root = loader.load(bla); primaryStage.setTitle("Hello World"); primaryStage

How to import database data into combo box in javafx

瘦欲@ 提交于 2019-12-24 11:37:30
问题 Using this code I Initialized Combo box @FXML private ComboBox category; And get value using: String Category = category.getValue().toString(); And inserted value to mysql database. Now before inserting next value in category Combo box I need to import the values in the database to the drop down in Combo Box and value should be displayed in the combo box. 回答1: I recommend to read the values from the database and save it into a ObservableList, once you get all the values you can fill the

How to bind the text of a textarea in fxml to a custom property in the controller?

我只是一个虾纸丫 提交于 2019-12-24 11:27:53
问题 I have a fxml file: <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="my.AppController"> <children> <TextArea prefHeight="200.0" prefWidth="200.0" text="${ddd}"/> </children> </HBox> You can see I want to use ${ddd} to bind

JavaFX FXMLLoader getController NullPointerException

限于喜欢 提交于 2019-12-24 09:47:36
问题 I have a project in school where I have to develop a program where you first can choose whether you want to save/read to/from a SQL DB or to save/read to/from XML. I've made a GUI where you can choose between both methods. The GUI closes after the user clicks on one of the buttons and the MainMenu GUI opens. Now I need to know in the MainMenuController what the user choose. I found online a Method to call the MainMenuController inside the first controller, with FXMLLoader.getController() .

JavaFX FXMLLoader getController NullPointerException

你说的曾经没有我的故事 提交于 2019-12-24 09:45:05
问题 I have a project in school where I have to develop a program where you first can choose whether you want to save/read to/from a SQL DB or to save/read to/from XML. I've made a GUI where you can choose between both methods. The GUI closes after the user clicks on one of the buttons and the MainMenu GUI opens. Now I need to know in the MainMenuController what the user choose. I found online a Method to call the MainMenuController inside the first controller, with FXMLLoader.getController() .

javafx WebView Method contextMenuEnabled could not be found warning

给你一囗甜甜゛ 提交于 2019-12-24 09:43:23
问题 I get the following warning and stack trace when I traverse to a screen containing a WebView in my javafx application. However the WebView is displayed and works fine. fxml tag <WebView fx:id="webViewId" contextMenuEnabled="false" focusTraversable="false" layoutX="115.0" layoutY="255.0" prefHeight="210.0" prefWidth="280.0" visible="false" /> Stack trace WARNING: Failed to set class javafx.scene.web.WebView.contextMenuEnabled using class javafx.scene.web.WebViewBuilder java.lang

JavaFX - Access fx:id from nested FXML

本小妞迷上赌 提交于 2019-12-24 08:57:39
问题 So, this is my main FXML file, called 'Home.fxml': <VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"> <fx:include source="MenuBar.fxml" /> <Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Welcome to MSMusic" textAlignment="CENTER"> <font> <Font size="62.0" /> </font> </Label> <fx:include source=

JavaFX styling TableColumn cells

大兔子大兔子 提交于 2019-12-24 07:50:26
问题 I am building a TableView in Gluon Scene Builder. I want to have a different background colour for cells in each column. Can I do this just through the FXML file and CSS? With a CSS style class .column-1 I can do: .column-1 {-fx-background-color: white;} Except that also styles the column header! There doesn't seem to be a way to specify column cells only. I have seen examples where people have managed it through java code - but doesn't this defeat the point of JavaFX having this CSS/FXML

Using initialize method in a controller in FXML?

扶醉桌前 提交于 2019-12-24 03:45:35
问题 I have a Java application with a view written in FXML. I am wanting to select a default tab, so when the program launches the first tab is shown as selected. I have seen the best way to do this is create an initialize() method in the controller and annotate it with @FXML which should the be loaded. For some reason though, the method is never executed. Code is below. MainApp.java import controller.Controller; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx

FXMLLoader get controller returns null

给你一囗甜甜゛ 提交于 2019-12-24 02:25:10
问题 I have a recursive case of FXML loading needed here. If I choose to View an Objective, it takes me to another instance of the screen that loads a list of Strategy objects. If I choose to view a Strategy, it takes me to another instance of the screen that loads a list of Tactic objects. If I view a Tactic, it takes me to another instance of the screen that loads a list of Task objects. Naturally, I decided to use a base controller class, ViewChildItemController to handle inheritance. Then I