JavaFx 无法正确呈现
JavaFx not rendering properly
我的代码由两个 类 组成,一个 MainGUI.java 和 Screen.java
我打算为不同的屏幕制作不同的 类 并在需要时渲染它们
这是我的当前代码 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
的代码
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 的屏幕截图:
我不知道哪些信息会有帮助,但我正在使用 jre1.8.0_25
正如您从图像中看到的那样,表单没有正确显示文本,并且下方还有一个灰色矩形。
用户报告说通过命令行选项绕过硬件渲染管道解决了他们系统上的问题:
-Dprism.order=sw
请注意(自 Java 8 起)上述命令行开关是 Oracle JavaFX 运行时的一个未记录且不受支持的功能。
参见:
- How to disable or bypass Hardware Graphics Acceleration(Prism) in JavaFX
我之前在 Whosebug 上看到过为 JavaFX 应用程序发布的类似图片(尽管我找不到重复的问题)。我永远无法复制这些图像,也不知道究竟是什么原因造成的。该应用程序可能 运行 在过时的视频卡或视频卡驱动程序上 JavaFX 不支持。
我的代码由两个 类 组成,一个 MainGUI.java 和 Screen.java 我打算为不同的屏幕制作不同的 类 并在需要时渲染它们
这是我的当前代码 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
的代码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 的屏幕截图:
我不知道哪些信息会有帮助,但我正在使用 jre1.8.0_25
正如您从图像中看到的那样,表单没有正确显示文本,并且下方还有一个灰色矩形。
用户报告说通过命令行选项绕过硬件渲染管道解决了他们系统上的问题:
-Dprism.order=sw
请注意(自 Java 8 起)上述命令行开关是 Oracle JavaFX 运行时的一个未记录且不受支持的功能。
参见:
- How to disable or bypass Hardware Graphics Acceleration(Prism) in JavaFX
我之前在 Whosebug 上看到过为 JavaFX 应用程序发布的类似图片(尽管我找不到重复的问题)。我永远无法复制这些图像,也不知道究竟是什么原因造成的。该应用程序可能 运行 在过时的视频卡或视频卡驱动程序上 JavaFX 不支持。