fxml

How to bind stage resizing with resizing of components?

自闭症网瘾萝莉.ら 提交于 2019-11-27 01:09:19
问题 I have a JavaFX 2.0 application with FXML. I want the components (TextFields, ComboBoxes, layouts, and so on) to be resized when a window with an application is resized. So... As it is written on Oracle documentation for JavaFX, to make something like this with shapes, there are a few special properties to shapes: When building GUI applications with JavaFX, you will notice that certain classes in the API already implement properties. For example, the javafx.scene.shape.Rectangle class

Customize ListView in JavaFX with FXML

折月煮酒 提交于 2019-11-27 00:14:52
I want to make a customize list view in javafx. Here I need to bind multiple component in list cell as follow, like one label, one textfield, one button under one HBox and two button, one hyperlink, one label in another HBox and these HBox comes under one VBox and this VBox comes under the single list cell and it will repeat and make a list View. The code is <ListView fx:id="ListView" layoutX="0" layoutY="30" prefWidth="600" prefHeight="300"> <HBox fx:id="listBox" alignment="CENTER_LEFT"> <padding><Insets top="5" bottom="5" left="5"></Insets> </padding> <HBox alignment="CENTER_LEFT" prefWidth=

Can't load FXML in another package (JavaFX)

房东的猫 提交于 2019-11-26 23:43:20
问题 For some reason I'm getting an error when I try to load an FXML which is in a different package: MainApp.java " FXMLLoader loader = new FXMLLoader(); System.out.println("view folder: " + MainApp.class.getResource("view/RootLayout.fxml")); // returns null loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml")); Folder structure: Error message: Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect

getHostServices().showDocument() in a FXML File

旧城冷巷雨未停 提交于 2019-11-26 23:43:05
问题 Is there any easy way to put into the toHomepage() method the getHostServices().showDocument() command somehow, instead of doing lines and lines of code, so the code should look clean and simple? package sample; import javafx.application.HostServices; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; public class Controller { @FXML private Button facebookButton; @FXML void toHomepage(ActionEvent event) { } } If I press the button, it should directly

JavaFx, Problems with @FXML

本秂侑毒 提交于 2019-11-26 23:16:51
I'm new in java, so I have to ask you for help :P. I'm creating very simple program, but I stucked on verifying password and login textField. I'm wondering what is wrong with that code, can you help me? Controller package sample; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.PasswordField; import java.awt.*; public class Controller { @FXML public TextField login,password; public void LoginButtonClicked(ActionEvent event) { if(login.getText().equals("yes")&&password.getText().equals("yes")) { System.out.print(

JavaFX Panel inside Panel auto resizing

你离开我真会死。 提交于 2019-11-26 22:36:27
问题 I have a JavaFX application which has only one FXML file. In this file I have one AnchorPane which has a StackPane inside it. Here is the screenshot: When I start this application, I want to resize StackPane automatically with the AnchorPane. Thus; StackPane will get the current avaliable width and height automatically. At the moment when I resize the application, AnchorPane is being resized automatically but StackPane stays as his fixed size. How can I resize the StackPane automatically and

How to pass object created in FXML Controller1 to Controller2 of inner FXML control

蹲街弑〆低调 提交于 2019-11-26 22:12:26
I have JavaFX 2.0 application, which consists of two FXML files, and 2 Controllers for them + one "main" .java file. At the start time, FXML1 is initialized, like this: public void start(Stage stage) throws Exception { stage.setTitle("Demo Jabber JavaFX Chat"); Parent root = FXMLLoader.load(getClass().getResource("fxml_example.fxml"), ResourceBundle.getBundle("fxmlexample.fxml_example")); Scene scene = new Scene(root, 226, 264); stage.setScene(scene); scene.getStylesheets().add("fxmlexample/fxmlstylesheet.css"); stage.show(); } Then, when a button from scene1 is clicked, in its event handler

Error loading fxml files from a folder other than the bin folder

微笑、不失礼 提交于 2019-11-26 21:57:34
问题 I am a fairly new java programmer. I only have about five weeks of experience, starting from zero, and I am having problems getting javafx fxml files created in Scene Builder to load correctly if they are not in the same folder as the controller classes. I am using Win7x64 running jre7x86 for this build Eclipse Juno Service Release 1 Build id: 20120920-0800 jre version 1.7.0_07 javaFx version 2.2.1-b03 SceneBuilder version 1.0-b50 My scene loader code is private static final String RESOURCE

Java FX fxml on Action

。_饼干妹妹 提交于 2019-11-26 21:48:46
问题 I want to add a method to a button which is defined in my Controller class in the console is only an error which tells me that it couldn't find the method here is the code sample.fxml <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="sample.Controller">

JavaFX pass values from child to parent

谁都会走 提交于 2019-11-26 21:04:42
问题 I have one parent controller which contain one button. When I click on button it open new window and show some data into table. The code I have used for opening window is Stage stage = new Stage(); FXMLLoader fxmlLoader = new FXMLLoader( getClass().getResource("../layout/SearchCustomer.fxml")); Parent parent = (Parent) fxmlLoader.load(); Scene scene = new Scene(parent); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(parent.getScene().getWindow()); stage.setScene(scene); stage