JavaFx无法正确呈现 [英] JavaFx not rendering properly

查看:237
本文介绍了JavaFx无法正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码由两个类组成,一个是MainGUI.java和Screen.java
我打算为不同的屏幕制作不同的类,并在需要时渲染它们

My code consists of two classes one the MainGUI.java and the Screen.java I intend to make different classes for Different Screens and render them when needed

这是我对 MainGUI.java的当前代码

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;


public class MainGUI extends Application{

    public static void main(String[] args) {
        launch(args);

    }

    @Override
    public void start(Stage pStage) throws Exception {

        Screen firstScreen = new Screen();
        Scene mainScene = new Scene(firstScreen );
        pStage.setScene(mainScene);
        pStage.setTitle("TestProg");
        pStage.show();
    }
}

这是Screen.java的代码

This is the code for Screen.java

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;



public class Screen extends VBox{
    private final Label L1 = new Label("Label 1");
    private final Label L2 = new Label("Label 2");
    private final TextField F1 = new TextField();
    private final TextField F2 = new TextField();
    private final Button B1 = new Button("This is a button");

    Screen(){
        super();
        showStuff();
    }
    private void showStuff(){
        this.setSpacing(5);
        this.setAlignment(Pos.CENTER);
        this.setPadding(new Insets(10,0,0,10));
        HBox Box1 = new HBox(L1,F1);
        HBox Box2 = new HBox(L2,F2);
        this.getChildren().addAll(Box1,Box2,B1);
    }
}

这是我运行后获得的GUI的屏幕截图代码:

This are the screenshots of the GUI i get after running the code:


I我不知道哪些信息会有所帮助,但我正在使用 jre1.8.0_25

I have no idea what information would be of help but but I'm using jre1.8.0_25

从图像中可以看出表格没有正确显示文本,下面还有一个灰色矩形。

As you can see from the images the Forms do no show the text properly and also there is a gray rectangle below.

推荐答案

用户报告绕过硬件渲染管道命令行选项修复了系统上的问题:

The user reports that bypassing the hardware rendering pipeline via a command-line option fixed the issue on their system:

-Dprism.order=sw

请注意(从Java 8开始)上述命令行开关是Oracle JavaFX运行时的未记录且不受支持的功能。

Note that (as of Java 8) the above command-line switch is an undocumented and unsupported feature of the Oracle JavaFX runtime.

参见:

  • How to disable or bypass Hardware Graphics Acceleration(Prism) in JavaFX

我之前在StackOverflow上看过为JavaFX应用发布的类似图片(虽然我找不到重复的问题) 。我永远无法复制图像,也不知道究竟是什么原因造成的。可能,该应用程序运行在JavaFX不支持的过时视频卡或视频卡驱动程序上。

I've seen similar images posted for JavaFX apps on StackOverflow before (though I can't locate the duplicate questions). I could never replicate the images and don't know exactly what causes them. Likely, the application is running on an out of date video card or video card driver that is not supported by JavaFX.

这篇关于JavaFx无法正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆