javafx

Multi-threading from PreLoader - JavaFX

不羁的心 提交于 2021-01-28 17:55:50
问题 I'm developing a JavaFX application that requires resources to be loaded in from a file before the main Application stage can be launched. My solution to accomplish this task is to use a PreLoader so that the user can't interact with the application until the resources have been loaded (pretty standard stuff). I have a class extending the PreLoader class that creates an object that loads a .fxml file which is what the PreLoader scene will display. It works all nice and dandy until I try to

How to pass parameters to a controller's constructor when using `<fx:include>`?

て烟熏妆下的殇ゞ 提交于 2021-01-28 17:52:01
问题 I am learning JavaFX, and I have come across an issue involving the instantiation of controllers that I can not seem to solve. Essentially, I am wondering if it is possible to do one of the following: Pass a parameter to the constructor of the controller when including FXML with <fx:include> ; or Specify a custom controller instance to use when including an FXML file with <fx:include> . Note that these issues are related. In fact, the reason I am asking about option (2) is because it would

Drag Drop Swing to JavaFX not working without debug mode

柔情痞子 提交于 2021-01-28 14:10:23
问题 I have a code that gets a Drag event coming from a Swing application. The code then drop the elements into a JavaFX TableView. This code works perfectly if I run in Debug mode. But it does not work if I run out of Debug. private static final DataFormat customFormat = new DataFormat("application/x-java-serialized-object"); this.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent event) { event.acceptTransferModes(TransferMode.ANY); event.consume(); } }); this

JavaFX SceneBuilder: ClassNotFoundException when loading custom control

这一生的挚爱 提交于 2021-01-28 11:30:36
问题 I see that there are many posts about this, some slightly recent, some much older. Nonetheless, I would like to share my own experience because I am facing this issue and I cannot seem to find a solution. First of all, the context : I use Intellij IDEA Community Edition 20018.2.2 from 21st of August 2018 I use Scene Builder from GLUON, version 8.5.0 (latest as of this post) I use the JDK & JRE 64 bits version 8.181 (latest as of this post) The situation: I am writing a chat app. I have a

How to fix “(java:22494): Gdk-WARNING…”

。_饼干妹妹 提交于 2021-01-28 11:10:02
问题 I am writing a javafx program and I need the panel to update at a constant rate. Right now it is set to update every second. But I got this error, which is usually (but not always) followed by a glitch in the panel when the whole scene becomes distorted (it like mirrors in on itself in a weird choppy x pattern. hard to explain). Full error: (java:22494): Gdk-WARNING **: 18:38:59.118: XSetErrorHandler() called with a GDK error trap pushed. Don't do that. This is the code I have for the timer:

Sorting a Text File in JavaFX

给你一囗甜甜゛ 提交于 2021-01-28 10:09:53
问题 So I can successfully create a score board, and then dynamically update this scoreboard with the 3 variables. However, I now need to sort the scoreboard based on the score (so the variable score here) and put the top 10 scores on the TextArea. How do I do this using a Collection Sort? The method which writes the 3 variables into the Text File public void newScore() { try (BufferedWriter bw = new BufferedWriter(new FileWriter("xxxxx/gameScores.txt", true))) { int score = player.getPoints();

Execute and wait for multiple parallel and sequential Tasks by using a Arraylist of Tasks in JavaFX

我怕爱的太早我们不能终老 提交于 2021-01-28 09:36:30
问题 I'm looking for a suitable way to display the processing time of parallel running Tasks on a separate stage. I want to execute different tasks combined in an ArrayList - one after the other. For this case I'm using a ThreadPool. After each executed list, I want to wait until all tasks are completed. Only when the tasks have reached the status „succeeded“, I want to do something in the MainThread. After that I want to execute another list of tasks and visualize them on a separate stage as well

How to set the install path on a self-contained app JavaFX .deb (Debian) package

浪子不回头ぞ 提交于 2021-01-28 09:36:10
问题 I'm trying to generate a .deb file, containing a self-contained copy of my JavaFX application, using the Oracle JavaFX Ant fx:deploy Task. I've followed the samples on official documentation and my pom.xml configuration looks like this: <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>install</phase> <configuration> <target xmlns:fx="javafx:com.sun.javafx.tools.ant"> <manifestclasspath property="manifest.classpath" jarfile="$

How can I get a reference to the controller of an FXML?

对着背影说爱祢 提交于 2021-01-28 09:08:05
问题 I'm trying to make a small "Login then Main Menu" form using JavaFX and Gluon's Scene Builder. I've made 2 scenes so far, the first one is a "Login" screen in which I've connected a SQLite Database, after putting the right Username and Password it loads perfectly fine and it changes to the second scene. For each scene I use a different class (FXML / FXML Controller). In the second scene I want 2 labels that I use to change according to the Database's data (More specifically First_Name and

Understanding Javafx runtime errors [duplicate]

一世执手 提交于 2021-01-28 09:01:30
问题 This question already has answers here : java.lang.IllegalArgumentException: Invalid URL or resource not found (2 answers) Closed 2 years ago . I wrote code for Sokoban game by using JavaFX but not completed one, here has three parts, first initialization, two more functions as you see. When I run the program, it makes a bunch of errors and it is the first time for me to get such java errors, I think this is not a syntax error, please give me your feedback if you know how to solve this,