3

I'm using Linux and trying to switch from Oracle's JDK to OpenJDK and OpenJFX, but I'm having severe problems with JavaFX applications.

Take for example this simple program:

import javafx.application.Application;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;

public class AlertTest2 extends Application {
    @Override
    public void start(final Stage primaryStage) throws Exception {
        final Alert alert = new Alert(AlertType.INFORMATION, "test alert");
        alert.setContentText("content goes here");
        alert.showAndWait();
    }

    public static void main(final String... args) {
        launch(args);
    }
}

If I run it with the Oracle JDK version 8, it works perfectly fine and shows an alert window. But with OpenJDK and OpenJFX version 11, all I get is this:
enter image description here
I also tried ZuluFX version 8 (a build of OpenJDK with OpenJFX included), and it works correctly about 1 out of 8 times, the other times chopping the alert dialog as shown above.

Has anybody else encountered this problem? What could be causing it and how can I fix it?

1 Answers1

3

After some digging, I found this bug: https://github.com/javafxports/openjdk-jfx/issues/222

Here is a workaround (from that page) that seems to help:

alert.setResizable(true);
alert.setOnShown(ev -> Platform.runLater(() -> alert.setResizable(false)));
alert.showAndWait();