fxml

How to switch scenes in JavaFX

↘锁芯ラ 提交于 2019-11-27 16:21:40
问题 I have looked on many pages to try and find out how to switch scenes but I have been unsuccessful. I have a calculator and my goal is to select a menu option to change Calculators(ie: basic and scientific). Right now I am just testing so here is my code relevant to this question thus far (I am using Scene Builder): @FXML private MenuItem basic; @FXML private MenuItem testSwitch; public static void main(String[] args) { Application.launch( args ); } @Override public void start(Stage

One controller to 2 fxmls (JavaFX)

只谈情不闲聊 提交于 2019-11-27 16:21:29
Is possible to connect two FXML (JavaFX) files to one controller? I can't do this with changing "fx:controller" in each FXML file... Any ideas? jewelsea Yes, you can do this. Although, it can be done, I do not recommend this approach . Don't place a fx:controller attribute in either FXML. Create a new controller and set the same controller into separate FXMLLoader instances. CustomerDialogController dialogController = new CustomerDialogController(param1, param2); FXMLLoader summaryloader = new FXMLLoader( getClass().getResource( "customerSummary.fxml" ) ); summaryLoader.setController

Have multiple FXML files (created in SceneBuilder), but only one controller. Does each scene load it's own copy of the controller?

元气小坏坏 提交于 2019-11-27 14:51:54
I have multiple FXML files I have created in SceneBuilder and one controller file. When I edit a value (say for instance, an integer value) in one scene, and then switch scenes, that value does not seem to have been changed in the new scene. When loading the fxml file for a scene, is my program loading a copy of the controller file just for (and used only by) that fxml file? Really appreciate any help you guys can give answering this question. jewelsea Your controller file is a Java source file which gets compiled to a single Java class from which many Java object instances may be created. At

Binding a Label's text property (in an FXML file) to an IntegerProperty (in a controller)

守給你的承諾、 提交于 2019-11-27 14:44:17
I've set up a data binding between a Label in an FXML file and an IntegerProperty in the associated controller. The problem is that, while the label gets set to the correct value upon initialization, it is not updating when the property's value changes. FXML file <?xml version="1.0" encoding="UTF-8"?> <?import java.net.*?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.text.*?> <GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="application.PaneController" minWidth="200"> <Label id="counterLabel" text="${controller

sort tableview with drag and drop (rows)

旧街凉风 提交于 2019-11-27 14:08:09
问题 my aim is to sort a tableview with drag and drop. I followed this example: http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm For drag and drop I added the fxml via Scene Builder <TableView fx:id="tableView" onDragDetected="#dragDetected" onDragDropped="#dragDropped" onDragOver="#dragOver" and made the controllers @FXML private void dragDetected(MouseEvent event) { System.out.println("dragDetected"); Integer idx; idx = tableView.getSelectionModel().getFocusedIndex

How to create multiple javafx controllers with different fxml files?

北慕城南 提交于 2019-11-27 11:49:49
I've been looking at some blogs and other stackoverflow questions, and I'm not seeing a direct answer to my question. I am creating a javafx gui client and I want to have my menubar be one controller in one fxml and then i want the content area to be additional fxml files. The login screen will be one fxml, after the login screen will be the main content of the application and that will be in one fxml. How do i go about doing this? I just don't want to have all of my code for my login, menubar, and main content in the same file. This is an image of what i am working on: Use FXML as components

close fxml window by code, javafx

99封情书 提交于 2019-11-27 10:26:33
问题 I need to close the current fxml window by code in the controller I know stage.close() or stage.hide() do this in fx how to implement this in fxml? I tried private void on_btnClose_clicked(ActionEvent actionEvent) { Parent root = FXMLLoader.load(getClass().getResource("currentWindow.fxml")); Scene scene = new Scene(root); Stage stage = new Stage(); stage.setScene(scene); stage.show(); } but it doesn't work! All help will be greatly appreciated. Thanks! 回答1: give your close button an fx:id, if

How do I make a mouse click event be acknowledged by a TreeItem in a TreeView?

∥☆過路亽.° 提交于 2019-11-27 09:54:05
The fxml file is as follows (headers omitted): <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" fx:controller="com.github.parboiled1.grappa.debugger.mainwindow.MainWindowUi"> <top> <MenuBar BorderPane.alignment="CENTER"> <Menu mnemonicParsing="false" text="File"> <MenuItem fx:id="loadInput" mnemonicParsing="false" text="Load file" onAction="#loadFileEvent"/> <MenuItem fx:id="parse" mnemonicParsing="false" text="Parse" onAction

How do I access a UI element from another controller class in JavaFX?

前提是你 提交于 2019-11-27 08:28:26
I have a JavaFX / Java 8 application written with NetBeans 8 (no SceneBuilder ). My application has a main window that has its own FXML file (primary.fxml) and its own controller class (FXMLPrimaryController.java). One of the items in the FXML is a TextArea . Some of the methods in FXMLPrimaryController.java are about appending to that TextArea . This application now spawns a second window (another "stage") with its own FXML (second.fxml) and its own controller class (FXMLsecondController.java). Within the second controller class, how can I access the TextArea in the primary? Here's a sample

Styling a JavaFX 2 button using FXML only - How to add an image to a button?

我的梦境 提交于 2019-11-27 07:49:09
I want to change the styling of a button, most of the threads here and the articles on the internet show how to do it using Java code, which I don't see it as a real good solution, is there any way for example to set a button with some text and an image inside it all by using FXML only (no Css) ? jewelsea Solution using only fxml As tarrsalah points out, css is the recommended way of doing this, though you can also do it in fxml if you prefer: <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <