为什么我的网格窗格中没有显示 myLabel 内容,这很奇怪,其他所有内容都在显示..
我已经尽我所能。请有任何帮助
这是我的代码片段和结果照片
@Override public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 1180, 650);
stage.setScene(scene);
stage.setTitle("Prayer Time Display");
scene.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm());
GridPane Mainpane = new GridPane();
scene.setRoot(Mainpane);
Mainpane.setGridLinesVisible(true);
Mainpane.setId("Mainpane");
GridPane prayertime_pane = new GridPane();
prayertime_pane.setId("prayertime_pane");
prayertime_pane.setPadding(new Insets(20, 20, 20, 20));
prayertime_pane.setAlignment(Pos.BASELINE_CENTER);
prayertime_pane.setVgap(7);
prayertime_pane.setHgap(35);
GridPane moon_pane = new GridPane();
moon_pane.setGridLinesVisible(true);
moon_pane.setPadding(new Insets(10, 10, 10, 10));
moon_pane.setAlignment(Pos.BASELINE_CENTER);
moon_pane.setVgap(10);
moon_pane.setHgap(10);
myLabel.setText("hello");
moon_pane.setConstraints(myLabel, 0, 0);
moon_pane.getChildren().add(myLabel);
ImageView Moon_img = new ImageView(new Image(getClass().getResourceAsStream("/Images/Full_Moon.png")));
Moon_img.setFitWidth(100);
Moon_img.setFitHeight(100);
moon_pane.add(Moon_img, 1, 0);
Text next_moon_text = new Text("13/02");
next_moon_text.setId("prayer-text-english");
moon_pane.setHalignment(next_moon_text,HPos.LEFT);
moon_pane.setValignment(next_moon_text,VPos.CENTER);
moon_pane.setConstraints(next_moon_text, 2, 0);
moon_pane.getChildren().add(next_moon_text);
Mainpane.add(moon_pane, 8, 1,3,2);