fxml

LoadException: Root value already specified on custom control

旧城冷巷雨未停 提交于 2019-12-11 12:59:08
问题 Example below causes javafx.fxml.LoadException: Root value already specified. The code is written according to example here: http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm Code: public class NavigationView extends ButtonBar { private static final String defaultTemplate = "/fxml/navigator.fxml"; public NavigationView() { this(null); } public NavigationView(URL resource) { //FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("custom_control.fxml")); if( resource

How do you get a ScrollPane that is placed in the center of a BorderPane to work?

馋奶兔 提交于 2019-12-11 12:04:51
问题 I have a program where i have a rootLayout made from a BorderPane. When i press a button in this rootLayout i place a new fxml view into the center of the the borderPane using .setCenter(). The view i am placing into the borderPane consists of an AnchorPane that has a scrollPane as it's child element and when i run this view by itself the scrolling works. However after placing the view into the borderPane it stops working. The area in the scrollPane doesnt move at all when i scroll down or up

How to set preferred width and height in fxml dynamically based on screen resolution javafx

妖精的绣舞 提交于 2019-12-11 11:54:30
问题 I am new to javafx. Is it possible to dynamically set preferred width and height in an fxml file based on screen resolution? I know how to get screen resolution and set it to stage: Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); My question is about dynamically setting prefWidth and prefHeight in fxml files. Also I want to know if I can programmatically change property values in the

OnKeyPressed event not triggered on TableRow in TableView Javafx8

谁都会走 提交于 2019-12-11 11:32:04
问题 I'm trying to have a KeyEvent handler on a TableRow of TableView, but the handler doesn't get called. I'm aware that a handler can be registered on the TableView and use the selectionmodel/ focus model to get the slected or focussed item but i want to register a key event on row for a specific use case. The documentation of onKeyPressed event says, Defines a function to be called when this Node or its child Node has input focus and a key has been pressed. The function is called only if the

javafx how to transfer variable values from one controller to another [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-11 11:16:31
问题 This question already has answers here : Passing Parameters JavaFX FXML (11 answers) Closed 5 years ago . i am new to javafx and i want to transfer variable values from one controller to another and i have no idea how to do this. so please help me. for example: i want to display username from first login window to second dashboard window so what should i do to save userid in one variable and send it to second window and display there in a label . code test: import java.net.URL; import java

How to add node to another node's child in FXML?

微笑、不失礼 提交于 2019-12-11 11:07:26
问题 Example of what I'd like to get, written in Java code: public class Main extends Application { private static Scene scene; public static void main(String[] args) { launch(args); } @Override public void init() throws IOException { // Load root pane from FXML file. URL url = getClass().getResource("sample.fxml"); StackPane root = FXMLLoader.load(url); // Create scene for a root node on JavaFX thread. Platform.runLater(() -> scene = new Scene(root, 600, 400)); } @Override public void start(Stage

JavaFX and FXML. When are the references to components loaded into the controller class?

[亡魂溺海] 提交于 2019-12-11 09:33:47
问题 I have a very simple fxml file, with a checkbox: ... <AnchorPane id="AnchorPane" xmlns:fx="http://javafx.com/fxml" fx:controller="jfx01.T01"> ... <CheckBox fx:id="checkBox1" text="CheckBox" /> ... the very simple controller class is the following: public class T01 extends Application { @FXML protected CheckBox checkBox1; @Override public void start(Stage primaryStage) throws IOException { Parent root = FXMLLoader.load(getClass().getResource("t01.fxml")); primaryStage.setScene(new Scene(root))

JavaFX: load resource from other package - NetBeans

偶尔善良 提交于 2019-12-11 09:33:36
问题 I know there have already been some questions about relative paths, but I Keep failing to get JavaFX FXML loader to load a resource from a package other than itself. The loading class is located in the package gui.controllers and the fxml file BarSheet.fxml is located in the package gui.resources . What should i now put in : FXMLLoader myLoader = new FXMLLoader(getClass().getResource("src/gui/resources/BarSheet.fxml")); Thanks in advance 回答1: SOLVED: The fault was in the fact that my fxml

How to pass data from Java to FXML? [duplicate]

孤者浪人 提交于 2019-12-11 09:06:59
问题 This question already has answers here : Passing Parameters JavaFX FXML (11 answers) Closed 3 years ago . In the Controller(or maybe the Main or another file, I'm not sure how all this works), we have the following: String foo = "Foo."; And in Scene Bilder-generated FXML, something like this: <Button mnemonicParsing="false" prefHeight="25.0" prefWidth="61.0" text="Browse" /> How do I make the value of foo appear as the text on the button? And where should I store it, the controller or

Gluon AppBar keep in the view

徘徊边缘 提交于 2019-12-11 08:10:07
问题 I'm trying to build a message window with App Bar on the top This screen consist of Gluon App Bar on the top and VBox in bottom which has rest of the element shown in the screen. Issue is when i click on the text area to enter text the App Bar goes out of scope. Is there a way I can set App Bar to be always on top? 回答1: If you are deploying your app on Android, the TextField and TextArea controls include a built-in check: when those input controls get focused, if required the scene is moved