JavaFX rendering issue on OSX after java upgrade

2019-08-09 16:46发布

My app with javafx 3D objects was working fine until I upgraded java from 8u51 to 8u60. After the upgrade, the UI is displayed upside down. Here is what I get with the following test code. It seems the y axis is reversed in rendering but not in functionality.

I have tried to put -Dprism.order=sw as a VM option. This fixes the test problem, but then does not allow javafx 3D objects to be rendered.

Does anyone knows how to fix this java/javafx issue. I will try to download and install Java 8u51.

Note, I have read JavaFX Mac OS strange rendering .

enter image description here

import javafx.application.Application;
import javafx.scene.PerspectiveCamera;
import javafx.scene.SceneAntialiasing;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.scene.Scene;

public class TestAppj extends Application {
    public static void main(String[] args) {  Application.launch(args); }
        public void start(Stage primaryStage) {
            primaryStage.setTitle("Test Stage");
            TabPane tabbedPane = new TabPane(new Tab("Tools", new BorderPane()), new Tab("Things", new BorderPane()));
            MenuBar menuBar = new MenuBar(
                    new Menu("File", null, new MenuItem("Open"), new     MenuItem("New"), new MenuItem("Save")),
                new Menu("Edit", null, new MenuItem("Cut"), new MenuItem("Copy"),   new MenuItem("Paste")));
          BorderPane root = new BorderPane();
        root.setTop(new VBox(menuBar, new ToolBar()));
        root.setCenter(tabbedPane);
        Scene theScene = new Scene(root, 500, 500, true, SceneAntialiasing.BALANCED);
        theScene.setCamera(new PerspectiveCamera());
        primaryStage.setScene(theScene);
        primaryStage.show();
    }
}

1条回答
不美不萌又怎样
2楼-- · 2019-08-09 17:29

This is a shorter way to reproduce the bug you have found with 8u60 on Mac:

@Override
public void start(Stage primaryStage) {
    Scene scene = new Scene(new StackPane(new Label("Antialising\nBalanced")), 
            300, 300, true, SceneAntialiasing.BALANCED);
    primaryStage.setScene(scene);
    primaryStage.show();
}

Balanced Antialiasing

The problem is not in the camera, but just in the antialiasing.

Workaround for now on Mac: use SceneAntialiasing.DISABLED. That will work as usual and you will be able to add 3D objects.

查看更多
登录 后发表回答