fxml

I want to load new FXML file with some parameters from the other Controller Files

馋奶兔 提交于 2019-12-04 07:06:26
问题 I already read next answers about passing parameters, but they didn't help me. passing-parameters-javafx-fxml javafx-from-the-trenches-singleton-controllers Below is my effort to open new FXML view from event handler which failes to pass parameter. Kindly looking for help. MainController.java @FXML private void handleButtonAction(ActionEvent event) throws IOException { Context currentContext = new Context(); URL url = getClass().getResource("ManageTemplateChild.fxml"); FXMLLoader fxmlloader =

JavaFX access parent Controller class from FXML child

扶醉桌前 提交于 2019-12-04 06:39:39
using JavaFX for an application and I have a Main.fxml file with some fxml child files inside it. I would like to access to MainController class of Main.fxml from the child Controllers. I'll try to explain better with an example: MainFxml: <HBox fx:controller="MainController.java"> <fx:include source="child.fxml"/> </HBox> MainController: public class MainController implements Initializable { private String string; public void setString (String string) { this.string = string; } ChildFxml: <HBox fx:id="child" fx:controller="ChildController.java"> <Button text="hello" onAction="#selectButton"><

Why am I getting a stackoverflow when loading my fxml?

南楼画角 提交于 2019-12-04 05:53:15
问题 I've adjusted my controller constructor and fxml so that all setup of the fxml to the controller is in the fxml except for the FXML construction and the fxml loading. Here is my controller: public class MainOverviewTab extends Tab { @FXML private AnchorPane content; public MainOverviewTab() { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("main_overview_tab.fxml")); // fxmlLoader.setRoot(content); // fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (Exception e)

Using FXML to Create ContextMenu within a Pane

元气小坏坏 提交于 2019-12-04 05:52:42
I've got a working example for defining a ContextMenu on a Pane in JavaFX FXML, but am not sure it is optimal. Currently, only JavaFX standard controls (e.g. Button, TextField) define a property for specifying a popup ContextMenu. Yet I wanted to have a popup menu appear anywhere in a Pane, in my case a VBox. I took the approach of extending VBox to support a context menu. It is a 'clunky' solution but works. Is there a better approach? Am I missing some fundamental concept? Here is my solution... FXML: <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.*?> <?import javafx

JAVA FXCollections LoadException Class is not a valid type

混江龙づ霸主 提交于 2019-12-04 05:24:45
I'm trying to implement a TableView with some data with the help of this Tutorial . Im stuck on populating data from my "Person.java" to the TableView. I tracked the problem down to the part <Person firstName="Jacob" lastName="Smith" email="jacob.smith@example.com" /> inside the "fxmltableview.fxml" file at the very bottom. So it seems that for some reason my "observableArrayList" isn't allwed to contain "Person.java" objects. "String.java" is allowed. Im out of ideas for experementing with the files, as i read several times word by word through the tutorial and i don't see any difference

JavaFX custom controller factory

大憨熊 提交于 2019-12-04 04:58:31
I have been experimenting with the FXMLLoader and using the setControllerFactory method using a custom Callback<P,R> implementation. The ORACLE documentation says the following: An implementation might return a null value to indicate that it does not or cannot create a controller of the given type; in this case, the default controller construction mechanism will be employed by the loader. The result I want to achieve is that I can use a dependency injection framework to create any controllers that require parameters but I will let the FXMLLoader load any controllers that do not require

FXML set TableView column resize policy

孤街醉人 提交于 2019-12-04 03:29:47
问题 How can I set a TableView's resize policy from FXML? I tired this way, but it's not working: <TableView layoutX="20.0" layoutY="20.0" prefWidth="674.0" prefHeight="668.0" fx:id="tableView" fx:constant="CONSTRAINED_RESIZE_POLICY"> <columns> <TableColumn text="First Name" /> <TableColumn text="Last Name" /> <TableColumn text="Email Address" /> </columns> </TableView> 回答1: To set columnresize policy for tableview using fxml , you have to use <columnResizePolicy> tag . This will work on javafx 2

JavaFX CSS Button with Image - How to define the size of the image?

一世执手 提交于 2019-12-04 02:49:22
I am trying to insert an image in a button using JavaFX CSS. Although, I can do it easily using the "-fx-graphic" tag, I cannot find a way to resize the image in whatever size I want. I can do this through the following FXML code, where I give 30 to my preferred width of image, but I would like to do this with pure CSS. Is there any way to do that? FXML <Button text="Press Me"> <graphic> <ImageView fitWidth="30"> <image> <Image url="myImage.png"/> </image> </ImageView> </graphic> </Button> CSS #buttonWithImage { -fx-graphic: url("myImage.png"); } pdem I had the same problem and found a

FXML Variables not binding

Deadly 提交于 2019-12-04 02:38:55
问题 I am having an issue with my FXML injection. I have setup my program as far as I can tell but it seems that I am missing something. My code is below: Main: package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; public class Main extends Application { @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader

Creating a row index column in JavaFX

扶醉桌前 提交于 2019-12-04 02:35:01
问题 I have a JavaFX TableView that I'm populating with an ObservableList of Tasks. I've been trying to create a column that displays the index of each row, which serves as the ID for the tasks in the table, but I've tried the method here and similar methods from other sources with little success. My code for reference, which has no superficial errors (as far as Eclipse can tell): @FXML private TableColumn<Task, String> taskIndexCol; Callback<TableColumn<Task, String>, TableCell<Task, String>> cb