I am experiencing issues when porting a JavaFX application from version 17 to 21. Specifically, I’m having trouble setting the location of a Stage. I am using openJDK from https://adoptium.net/, javafx-sdk and javafx-jmods from https://gluonhq.com/products/javafx/. To better illustrate this issue, I’ve created a simple example:
import javafx.application.Application;
//import javafx.stage.Modality;
import javafx.stage.Stage;
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Stage stage = new Stage();
//stage.initModality(Modality.APPLICATION_MODAL);
//stage.initModality(Modality.WINDOW_MODAL);
//stage.initModality(Modality.NONE);
stage.initOwner(primaryStage);
stage.setTitle("Test App");
stage.setX(500);
stage.setY(500);
stage.setWidth(200);
stage.setHeight(100);
stage.showAndWait();
}
}
While javaSDK/javaFX versions 11 and 17 work correctly for me, version 21.0.5 on Ubuntu 24.04 (which also works fine on Windows 11) sets the window to location (0,0) in 8 out of 10 times.
Any advise?
p.s. I am not running on Wayland.
Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.