我的问题是,在以下构造中,不显示 ... 内的 GridPane 内的 BorderPane 内的粗体标记图像和标签。我将图像和标签放在另一个 BorderPane 中,因此 GridPane 的每一行都有更多样式选项。当只有一些标签在 BorderPane 内时,所有标签(包括它们自己的标签和 BorderPane 内的标签)都会显示,但现在所有标签都在它们各自的 BorderPane 内,不会显示任何标签。为 BorderPanes 设置 prefHeight 并没有什么不同。有任何想法吗?
编辑:在代码字段中标记粗体似乎不起作用。我说的是 GridPane.rowIndex="0" 上的所有内容。
提前致谢!
例子.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,0,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,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,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,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,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,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>
示例控制器.java
package examplePackage;
public class exampleController
{
}
主.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);
}
}