JavaFX / FXML:BorderPane中的ImageView和标签未显示

我的问题是,在以下构造中,不会显示…内GridPane内BorderPane内的加粗标记图像和标签。我将图像和标签放置在另一个BorderPane内,因此GridPane的每一行都有更多的样式选项。当只有某些标签位于BorderPane内时,将显示所有标签(单独的标签和位于BorderPane内的标签),但是现在所有标签都位于其各自的BorderPanes内,则不会显示任何标签。为BorderPanes设置prefHeight并没有什么不同。有什么想法吗?

编辑:将粗体标记为似乎在代码字段中无效。我正在谈论GridPane.rowIndex =“ 0”上的所有内容。

谢谢!

example.fxml

<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.TilePane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.control.CheckBox?>

<BorderPane fx:controller="examplePackage.exampleController" xmlns:fx="http://javafx.com/fxml">

<VBox>
    <TitledPane>
<!-- ................................................................................... -->
        <graphic>
            <BorderPane prefWidth="1312">
                <left>
                    <BorderPane>
                        <left>
                            <ImageView>
                                <Image url="file:///....png"/>
                            </ImageView>
                        </left>
                        <right>
                            <Label text="Text" style="-fx-padding:5"></Label>
                        </right>
                    </BorderPane>
                </left>
                <center> 
                </center>
                <right>
                    <BorderPane>
                        <left>
                            <StackPane prefWidth="32">
                                <ImageView>
                                    <Image url="file:///....png"/>
                                </ImageView>
                            </StackPane>
                        </left>
                        <right>
                            <StackPane prefWidth="28" style="-fx-padding:0,5,5; -fx-border-width:0px 0px 0px 0.5px; -fx-border-style: solid; -fx-border-color:#ffffff">
                                <ImageView>
                                    <Image url="file:///....png"/>
                                </ImageView>
                            </StackPane>
                        </right>
                    </BorderPane>
                </right>
            </BorderPane>
        </graphic>
<!-- ................................................................................... -->
        <GridPane>
            <columnConstraints>
                <ColumnConstraints percentWidth="5.0"/>
                <ColumnConstraints percentWidth="25.0"/>
                <ColumnConstraints percentWidth="25.0"/>
                <ColumnConstraints percentWidth="25.0"/>
                <ColumnConstraints percentWidth="20.0"/>
            </columnConstraints>

            <BorderPane prefHeight="30" GridPane.rowIndex="0" GridPane.columnIndex="0" style="-fx-border-color: rgb(0,0); -fx-border-width:0px 0px 0.5px 0px">
                <ImageView>
                    <Image url="file:///....png"/>
                </ImageView>
            </BorderPane>

            <BorderPane GridPane.rowIndex="0" GridPane.columnIndex="1" style="-fx-border-color: rgb(0,0); -fx-border-width:0px 0px 0.5px 0px">
            <Label text="Text">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            </BorderPane>

            <BorderPane GridPane.rowIndex="0" GridPane.columnIndex="2" style="-fx-border-color: rgb(0,0); -fx-border-width:0px 0px 0.5px 0px">
            <Label text="Text">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            </BorderPane>

            <BorderPane GridPane.rowIndex="0" GridPane.columnIndex="3" style="-fx-border-color: rgb(0,0); -fx-border-width:0px 0px 0.5px 0px">
            <Label text="Text">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            </BorderPane>

            <BorderPane GridPane.rowIndex="0" GridPane.columnIndex="4" style="-fx-border-color: rgb(0,0); -fx-border-width:0px 0px 0.5px 0px">
            <Label text="Text">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            </BorderPane>

            <Label text="Text" GridPane.rowIndex="1" GridPane.columnIndex="0">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            <Label text="Text" GridPane.rowIndex="1" GridPane.columnIndex="1">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            <Label text="Text" GridPane.rowIndex="1" GridPane.columnIndex="2">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>
            <Label text="Text" GridPane.rowIndex="1" GridPane.columnIndex="3">
                <font>
                <Font name="Arial" size="13"></Font>
                </font>
            </Label>

        </GridPane>
<!-- ................................................................................... -->
    </TitledPane>
</VBox>
</BorderPane>

exampleController.java

package examplePackage;

public class exampleController
{

}

Main.java

package examplePackage;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application
{
    @Override
    public void start(Stage primaryStage)
    {
        try {
            Parent root = FXMLLoader.load(getclass().getResource("example.fxml"));
            primaryStage.setScene(new Scene(root,1920,800));
            primaryStage.setTitle("exampleTitle");
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args)
    {
        launch(args);
    }
}

iCMS 回答:JavaFX / FXML:BorderPane中的ImageView和标签未显示

问题是我将标签直接放置在边框窗格中而没有“”标签来指定其对齐方式。

错误:

$this->getContainer()->get('router')
->setContext(
   (new RequestContext())
   ->setParameter('_locale','fr')
);

右:

<BorderPane GridPane.rowIndex="0" GridPane.columnIndex="1">
    <Label text="Text">
        <font>
            <Font name="Arial" size="13"></Font>
        </font>
    </Label>
</BorderPane>
本文链接:https://www.f2er.com/2297424.html

大家都在问