I am building a version of Risk in JavaFX with FXML for school. Now we want to be able to right click a button to decrease the amount of troops in a country and left click it to increase the amount. The left click was pretty self explanatory as it is just an onAction, but how would we check for
Tag: javafx
Which version of OpenJFX (JavaFX) and Scene Builder should I use with Amazon Corretto 11 (OpenJDK)?
In your opinion, what is the best version of OpenJFX (JavaFX) and Scene Builder should I use with Amazon Corretto 11 (OpenJDK)? Currently, until the date of this post, there are 2 versions of OpenJFX (JavaFX) and 2 versions of Scene Builder: Gluon’s JavaFX versions: JavaFX 11 LTS JavaFX 16 Latest Releas…
Can JavaFX realistically be used in a non-modular environment?
I’ve attempted to use JavaFX by following instructions found at: https://openjfx.io/openjfx-docs/ under “JavaFX and IntelliJ” -> “Non-modular with Maven” After completing steps 1 & 2 (Installation & Verification) I attempted to run a very simple program from IntelliJ r…
MediaPlayer.getTotalDuration().toSeconds() returns NaN when called in Initialize method
I am working on MediaPlayer using JavaFX to finish javaFX course. I am trying to set file total duration to the slider max property. Then I want to add Listener to the currentTimeProperty so the slider is tracking the timeline. I wrote a code that works perfectly fine: It works when I call it once the video i…
I have an array of Circle objects and I need to fill a circle if it is clicked. How do I write the event handling for this?
Is there any way to change the element at i without getting a “Local variable i defined in an enclosing scope must be final or effectively final” error? Answer If you look at the docs for MouseEvent, you will see that it has a source field that it inherits from EventObject: The object on which the…
GridPane: How to position a Label top-left?
How can I position the Label Label 1 at the top-left position of the cell? I tried to set the alignment of the label accordingly, but this didn’t do the trick. d Answer You need to modify the first RowConstraints and set the valignment property to VPos.TOP. The vertical alignment for the row. If set, wi…
Can you catch a “package x does not exist” error in Java?
I’m using this code to set the macOS dock icon of my JavaFX app: I can’t run the app on Windows because it throws the error “java: package com.apple.eawt does not exist” How can I catch a “package x does not exist” error or check if it exists at runtime? Answer You can̵…
How to launch JavaFX source code file from command line?
Since JDK 11, the java command can launch a java source code file, i.e. no need to first compile your java source code. Here is my java source code: I save this code as file HelloJavaFxWorld.java. I open a command prompt window and enter the following command. This is (part of) the output. How can I run a Jav…
Stage: Not resizing to Scene
I have a scene on a stage. The width of the scene is 337.0 pixels. However, when I add it to the stage, the size of the stage is 337.6 pixels which leaves a white gap at the right edge of the screen due to the 0.6 pixel difference. I tried using stage.sizeToScene(), but that’s not working. I also tried
IntelliJ Exe build not working as I expected
I am working on a JavaFX Application, which is a conferencing application. The application is running fine with IDEA. But my target is to build an exe from my application which would run standalone. I have configured an Artifact to build exe where I set the values for Application Class Title Vendor Version Na…