【发布时间】:2019-12-19 10:41:51
【问题描述】:
每当我尝试向我的 JavaFX 应用程序添加标签时,该应用程序使用了一个在其中绘制 3D 形状的 SubScene,我在 SubScene 中得到一个白色矩形。我什至不需要对标签做任何事情,它总是这样做。
没有标签的舞台图片
带有标签的舞台图片
我提供了一些带有标签的代码,虽然我找不到任何问题。
package UI;
import Cargo.CargoSpace;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.image.Image;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.scene.control.Label;
public class MainApp extends Application {
@Override
public void start(Stage stage) {
//Set Initial stage settings
stage.setTitle("Pentominoes - Group X");
stage.getIcons().add(new Image(Settings.pathToTitleBarImage));
stage.setResizable(false);
stage.setAlwaysOnTop(true);
//Main scene of the stage
HBox scenePane = new HBox();
scenePane.setPadding(Settings.mainScenePadding);
//SubScene containing the cargo space
CargoSubScene cargoSubScene = new CargoSubScene(new CargoSpace(Settings.cargoSpaceDims[0],Settings.cargoSpaceDims[1],Settings.cargoSpaceDims[2], 2));
scenePane.getChildren().add(cargoSubScene);
//SubScene containing the selections in the main menu
GridPane selectionLayout = new GridPane();
scenePane.getChildren().add(selectionLayout);
Label title = new Label("Pentominoes Phase 3");
selectionLayout.add(title, 0, 0);
//Adding main scene to the stage
Scene cargoScene = new Scene(scenePane, Settings.mainSceneSize[0], Settings.mainSceneSize[1]);
stage.setScene(cargoScene);
//Displaying the stage
stage.show();
}
public static void main(String[] args){
launch(args);
}
}
【问题讨论】:
-
请将所选解决方案标记为有用。
标签: java javafx graphics rendering