javafx

Extracting text from dynamically created textfields inside various rows of gridpane

风格不统一 提交于 2020-01-06 07:08:17
问题 I'm trying to create a grid with a textbox on each row where user can enter a number, and corresponding number of new rows are added. This works well, as shown below in the screenshot. Now I'm trying to extract the text from those textfields created based on the question "how many?" and since they are nested within various node elements, I'm having a hard time identifying the right way.Can anyone tell me what I'm doing wrong? I tried testing it using the save button, but I always go into the

How to solve the “Graphics Device initialization failed for : d3d, sw” Problem

好久不见. 提交于 2020-01-06 07:06:13
问题 I encountered the following RuntimeException when starting an application which uses JavaFX 11+: Graphics Device initialization failed for : d3d, sw Error initializing QuantumRenderer: no suitable pipeline found java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init

JavaFX CustomMenuItem strange behaviour with TextField

拜拜、爱过 提交于 2020-01-06 06:52:54
问题 maybe someone can explain the following behaviour - and hopefully, possible workarounds... thanks. When using a CustomMenuItem containing a TextField, the action of the MenuItem above gets triggered by pressing enter inside the textfield... unless the textfield has an actionlistener set (not added)... I need to use addEventHandler, not setOnAction... :-/ import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.CustomMenuItem; import javafx.scene.control

JavaFX FXML Application won't run

喜你入骨 提交于 2020-01-06 05:51:46
问题 I'm trying to follow the tutorial here. But, my IDE, Eclipse, doesn't seem to want to work with it. I've tried copying and pasting the code examples into my IDE, but the same error pops up. Unfortunately, no window is displayed. Please help me figure out what's wrong with this code. The error: Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke

How to orient the muzzle of a gun ? [JavaFX]

夙愿已清 提交于 2020-01-06 05:36:09
问题 I am creating a game in which you use guns and play against the computer/someone else. You can orient that gun with a slider. But I don't manage to orient the muzzle of the gun. I tried in different ways, nothing worked as expected. I googled a bit but I found nothing that worked and nothing that seems to have a chance of working. So I ask you, what haven't I tried yet ? What should I do different ? Here is a picture explaining what I said : Expectations Here is the concerned code : package

How to check which button (in fxml) has invoked a function in controller.java when both buttons have same onAction method

那年仲夏 提交于 2020-01-06 05:15:08
问题 If there are multiple buttons in an fxml file, with the sam onAction method , how to check which button has invoked the method in the controller.java file. Fxml code is like this <Button fx:id="b12", onAction="#push"> <Button fx:id="b13", onAction="#push"> Controller.java looks like this @FXML Button b12, b13; I want to write a function such that if it is invoked by the first button , then its id has to be printed and otherwise the second id. 回答1: As Slaw mentioned in their comment, you would

JavaFX- new Stage in a task

徘徊边缘 提交于 2020-01-06 04:52:07
问题 I want to open a new window from the task but for some reason after line Stage stage = new Stage the code stops executing, but there is no error. Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { Parent root = FXMLLoader.load(getClass().getResource("sample2.fxml")); Stage stage = new Stage(); System.out.println("Print"); stage.setTitle("My New Stage Title"); stage.setScene(new Scene(root, 100, 100)); stage.show(); return null; } }; It never prints out the

what does initialize() mean in javafx?

筅森魡賤 提交于 2020-01-06 04:50:08
问题 I wrote some code in my project, and I found that I should put my buttonlistener in the public void initialize() , or I can't use the button. I don't know what the initialize() mean in javafx , why I can't change it to another method name? This is initialize method in my code, I don't implement Initializable. So what't the mean of this in javafx? public void initialize() { weight_number1.setOnAction(e -> number(1)); weight_number2.setOnAction(e -> number(2)); weight_number3.setOnAction(e ->

Is it possible to draw graphs using JavaFX in a normal Java application?

≡放荡痞女 提交于 2020-01-06 04:04:10
问题 I want to draw some graphs of statistics gathered during a simulation I coded in Java. I decided to try JavaFX, as it has some great graphing abilities. However, as I've never used it before, I'm not sure if it's even possible to add JavaFX capabilities to a project that wasn't set up to do this initially. I've added the javafx library to my project, and copy pasted the JavaFX tutorial on line graphs at http://docs.oracle.com/javafx/2/charts/line-chart.htm (without the main function) to test

Getting position in Scene of a Node with localToScene(x,y) returns wrong value

邮差的信 提交于 2020-01-06 04:01:05
问题 I want to bind the position of a pane that pops up to the position of the Button calling it, and I tried doing so by callling button.localToScene(button.getLayoutX(),button.getLayoutY() . However the returned Point2D variable has the wrong X coordinate in it. I measured it in Gimp and its supposed to be at 320 but it returns me 586. Same story with localToScreen() btw, I dont even have 586 pixels of screen estate until the button already shows up, so its impossible for it to be at that