I am using a Mac with the latest version of Java (FX), macOS as well as IntelliJ IDEA CE. The problem is that when I resize a JavaFX Window, my Mac crashes instantly. Only when I press the power button for five seconds, the MacBook restarts. I created a normal IntelliJ JavaFX Project, with these automatically created files:
- HelloController.java
- HelloApplication.java
- hello-view.fxml
I didn't change anything and started the program. Everything works fine until you try to resize the window, the Mac crashes, you can not move the courser or anything else.
HelloApplication.java:
package com.example.demo;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Hello Controller.java:
package com.example.demo;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
public class HelloController {
@FXML
private Label welcomeText;
@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
}
}
hello-view.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<bottom>
<Button mnemonicParsing="false" text="Button" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
I have the same issue with the Border Pane (edited with Scene Builder).
My Hardware:
- MacBook Pro Mid 2012
- Dual-Core Intel Core i5 2.5 GHz
- 16GB 1600 MHz
- DDR3 1TB Samsung EVO 860 SSD
- Intel HD Graphics 4000 1536 MB
- macOS Catalina 10.15.7
Java (FX) Version:
I tried:
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.runtime.version: 17.0.1+12-LTS-39
javafx.runtime.version: 17.0.1+1
And:
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.runtime.version: 17.0.1+12-LTS-39
javafx.runtime.version: 18-ea+8
Does someone have the same issue, or know a way to fix this?