fxml

JavaFX: can controller be an abstract class?

吃可爱长大的小学妹 提交于 2019-12-11 02:59:54
问题 I have been working on this part of code for a day and just can't figure out why it always generates error. I have a controller and FXML. They worked perfectly. Then it came to my mind that I want to reuse this particular controller with a abstract updateSelect() function. Therefore, I change the controller to abstract. The code compiled just fine. Until I try to run this part of code. @FXML private void mnuProjMember_onClick(ActionEvent event) { mainContent.getChildren().clear(); FXMLLoader

fxml getController() returns null

江枫思渺然 提交于 2019-12-11 01:55:39
问题 I am newbie in JavaFX. Can anyone help me? Here is my code Stage stage = new Stage(); FXMLLoader loader = new FXMLLoader(); Parent root = (Parent) loader.load(getClass().getResource("FXMLMain.fxml").openStream()); FXMLMainController mainController = loader.getController(); mainController.setStage(stage); stage.setScene(new Scene(root)); stage.show(); ((Node) (event.getSource())).getScene().getWindow().hide(); loader.getController() returns null java.lang.NullPointerException at library

“Element does not define a default property” when @DefaultProperty is used

痴心易碎 提交于 2019-12-10 23:56:23
问题 I am trying to create a custom JavaFX element for use in FXML, but when FXMLLoader tries to parse it, it throws an exception that states: javafx.fxml.LoadException: Element does not define a default property. However, after doing some research, I believe that I am defining the default property properly. If I include the nestedCellValueFactory tags, everything works as expected. Java @DefaultProperty("nestedCellValueFactory") public class NestablePropertyValueFactory<S, T> extends

Saving user interface into fxml : javafx

老子叫甜甜 提交于 2019-12-10 19:55:36
问题 I have an javafx application which let's the user to add as much as buttons he/she wants. I load my main scene root from an fxml file which contains the default user-interface . As the user changes the interface, I change the scene using @FXML annotation. This changes are temporary and the user interface will be same as what it was, in the next time application run. So here's my question: How can I save the changes made to interface of the application during runtime to a new fxml file? 回答1: A

JavaFx TableView Columns don't fill the TableView Width

左心房为你撑大大i 提交于 2019-12-10 16:37:00
问题 I have a TableView generated with SceneBuilder and all the columns are FXML imports from other views, until there no problem, but the columns don't fill the width. I tried to fix this with scene builder and FXML, but no luck, all the sizes are computed. I tried to code it with a change listener that checks every time the window changes size to adapt the size of the columns. This works and the columns resize to the proper width (basically I am getting the table view width and divide it by the

FXML cellValueFactory for TreeTableColumn

那年仲夏 提交于 2019-12-10 15:25:14
问题 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: javafx.scene.control.TreeTableColumn$CellDataFeatures cannot be cast to javafx.scene.control.TableColumn$CellDataFeatures The FXML is written as follows <TreeTableView prefHeight="500.0" prefWidth="600.0" fx:id="customerContractsTable"> <columns> <TreeTableColumn prefWidth=

How to center scaled vector graphic on Button?

会有一股神秘感。 提交于 2019-12-10 15:15:41
问题 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 to create button without text with overlayed SVG image. Problem is that button image is displaced. <Button prefWidth="30" prefHeight="30"> <padding> <Insets top="0" right="0" bottom="0" left="0"/> </padding> <graphic> <Pane scaleX="0.3" scaleY="0.3"

changing text color of a Menu control in JavaFX with FXML/CSS

旧巷老猫 提交于 2019-12-10 15:02:08
问题 I want to change the text color of the Menu control in JavaFX . Currently, the background color of the whole Menu Bar is set to white and the default text color for displaying Menu -s is also white, so I cannot see the actual control, therefore I want to set the text color of the Menu ("File") to black. How do I do that? Here's the FXML portion: <?import java.lang.*?> <?import java.net.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import

javaFX - Field validation

不羁岁月 提交于 2019-12-10 14:11:20
问题 I am newbie to javaFX. I created one registration form using fxml. Now i want to implement the field validation functionality. I am trying to implement the validation for TextField but still I am not getting it. Please can anyone help me. thanks Naresh 回答1: Unfortunately, there is no validation framework within JavaFX. Even frameworks such as Granite Data Services had troubles with bean validation with JavaFX: http://granitedataservices.com/blog/2012/11/29/thoughts-about-javafx-and-bean

Code is working in jdk7 not in jdk8

落爺英雄遲暮 提交于 2019-12-10 12:19:33
问题 I took the sample code from How to create custom components in JavaFX 2.0 using FXML?. the code working fine in jdk7 but the checkbox and combo box values are not working in jdk8. I am not able to click the check box even and select the dropdown. Please guide me for the same. Please find the sample code below Package structure com.example.javafx.choice ChoiceCell.java ChoiceController.java ChoiceModel.java ChoiceView.fxml com.example.javafx.mvc FxmlMvcPatternDemo.java MainController.java