fxml

JavaFX custom control (TextField) not working

十年热恋 提交于 2019-11-30 12:44:55
I am trying to make a custom control with JavaFX and SceneBuilder 1.1. I have this code: FXML <?import libreria.javaFX.componentes.componenteTextField.*?> <AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml"> <children> <CustomComponent fx:id="pastaTxt" layoutX="69.0" layoutY="87.0" prefWidth="200.0" /> </children> </AnchorPane> CustomComponent.java package libreria.javaFX.componentes.componenteTextField; import javafx.scene.control.TextField; public class

How to call functions on the stage in JavaFX's controller file

穿精又带淫゛_ 提交于 2019-11-30 12:43:09
I am using javafx along with fxml , so I use the controller for the real coding . I need to do a few operations on the stage, such as getting its x- or y-axis position. I have tried stage.getX() & stage.getY , but they don't work(the stage name is high-lited as the error). How do I use such functions in my controller? I tried doing this in my main file: public int locationX = stage.getX(); and public double locationX = stage.getX(); But it doesn't work, instead makes the whole program one big error. So how do I get to do such functions in my controller file? Do I need to import something or do

JavaFX - How to get FXML Controller? [duplicate]

泪湿孤枕 提交于 2019-11-30 12:42:11
This question already has an answer here: Accessing FXML controller class 4 answers I have the following code: Parent parent = FXMLLoader.load(Main.class.getResource("JanelaPrincipal.fxml")); in the fxml file there is a reference to the controller class. How can I get the controller object? fxml: <AnchorPane id="AnchorPane" fx:id="root" prefHeight="768.0" prefWidth="1024.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="br.meuspila.javafx.JanelaPrincipalController"> ... jewelsea Instantiate an FXMLLoader and use an instance load method rather than a

FXML full reference?

◇◆丶佛笑我妖孽 提交于 2019-11-30 12:29:14
问题 I'm trying to learn JavaFX 2.0 + FXML, and i found it kind of uncomfortable to make fxml file, without knowing what i can put in it and what i can't. I mean which tags are possible in FXML, which attributes evety tag has? which values evety attribute can have, and so on. There are some examples in a web, but they don't show the hole capabilities of FXML. I've tried to use NetBeans and Eclipse plugins for JavaFX 2.0, but, both of them does not have any intelences for FXML, they just validate

IntelliJ IDEA - getClass().getResource(“…”) return null

南笙酒味 提交于 2019-11-30 11:01:11
I'm using IntelliJ IDEA 13.1.5, I used to work with Eclipse. I'm working on JavaFX application, I try to load FXML file within my MainApp class using getClass().getResource(). I read the documentation and I try several idea, at the end I have null . This is the hierarchy : dz.bilaldjago.homekode.MainApp.java dz.bilaldjago.homekode.view.RootLayout.FXML This is the code snippet I used: FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("view/RootLayout.fxml")); I tried other solution such giving the url from the root and using the classLoader the result is the same.

How to load content to JavaFX tabs dynamically?

吃可爱长大的小学妹 提交于 2019-11-30 10:15:06
I have a GUI, made using JavaFX with FXML. This GUI has a lot of components and not all of them are needed at one moment of time. For example, imagine a GUI that receives from its server part a list of cities. Each city is described on its own tab (and described with a lot of nodes). The set of cities contains 30 elements. When the GUI is launched, it asks the server for a list of the cities. The server returns a random "sub-set" of cities (so, it can be Moscow + Riga + New York or St.Petersburg + Tokyo, or only Amsterdam, or all 30 cities in one set). So. I have no need to have all 30 tabs in

JavaFX 1 FXML File with Multiple Different Controllers?

一笑奈何 提交于 2019-11-30 09:28:30
There are two different stages in my application that are help screens that use the same FXML file. Rather than create 2 FXML files, I would like to use just one and have two controllers that call the same fxml. The only problem is that the Controller is assigned in the FXML file. So, is there a way to change the assigned controller with code in the Controller class itself? I'd really like to avoid duplicating an FXML file just to change the Controller in each. Thanks in advance. You can remove the fx:controller="" assignment from the FXML file and assign the controller via the FXMLLoader

How to use FXMLLoader.load() - JavaFX 2

老子叫甜甜 提交于 2019-11-30 08:28:42
问题 I am building a JavaFX application using the JavaFX Scene Builder. The interface was created in the Scene Builder and a FXML file (main.fxml) was created. To use the interface in my application I must load the FXML file using the FXMLLoader, but there is a problem because the load() method returns an Object, and to build a Scene I need an instance of Parent class. Below is a piece of my MainClass. The compiler is giving an error because page is not of type Parent: Object page = FXMLLoader

JavaFX: FXML: How to make the child to extend its size to fit the parent pane?

江枫思渺然 提交于 2019-11-30 06:17:43
I have managed to load a child fxml(sub UI) under a parent fxml (mainMenu UI). I have created an AnchorPane with id "mainContent". This pane is bound to 4 sides and changes in accords to the stage. The child window will be loaded into the "mainContent" anchorpane. However, I can't figure out how to make the child to change along with its parent "mainContent". My child UI is called like this. @FXML private void mnuUserLevel_onClick(ActionEvent event) { FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml")); loader.setController(new DBeditEntityUserlevel()); try { Node n =

FXML full reference?

别说谁变了你拦得住时间么 提交于 2019-11-30 04:19:15
I'm trying to learn JavaFX 2.0 + FXML, and i found it kind of uncomfortable to make fxml file, without knowing what i can put in it and what i can't. I mean which tags are possible in FXML, which attributes evety tag has? which values evety attribute can have, and so on. There are some examples in a web, but they don't show the hole capabilities of FXML. I've tried to use NetBeans and Eclipse plugins for JavaFX 2.0, but, both of them does not have any intelences for FXML, they just validate open-close tags and other simple things, which evety XML editor can do. Maybe i've configured these