java - JavaFX - TitledPane 没有在 TitledPane 标题图形中显示 JFXButton 文本
问题描述
我正在使用 Accordion TitledPane 制作侧边栏菜单,每当我在 TitledPane 的标题图形中添加 JFXButton 时,它都非常适合其中但按钮文本没有显示。我在按钮内添加了 fontAwesomeIcon,我可以看到 fontAwesome Icon 但看不到按钮文本。此外,当 TiledPane 展开 JFXButton 文本时也不会显示。
下面是我的 FXML 代码
<VBox layoutY="76.0" maxWidth="-Infinity" prefHeight="664.0" prefWidth="250.0" style="-fx-background-color: #E5DEF3;" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="76.0">
<children>
<ImageView fitHeight="40.0" fitWidth="250.0" pickOnBounds="true" preserveRatio="true" />
<Accordion nodeOrientation="RIGHT_TO_LEFT">
<panes>
<TitledPane fx:id="tt1" alignment="CENTER_RIGHT" cache="true" contentDisplay="GRAPHIC_ONLY" graphicTextGap="4.0">
<graphic>
<JFXButton fx:id="ttbtn1" alignment="CENTER_RIGHT" contentDisplay="RIGHT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" prefHeight="40.0" prefWidth="218.0">
<graphic>
<FontAwesomeIconView size="1.5em" />
</graphic>
<font>
<Font size="14.0" />
</font>
</JFXButton>
</graphic>
<content>
<VBox alignment="TOP_CENTER" prefWidth="100.0">
<children>
<JFXButton alignment="CENTER" prefHeight="36.0" prefWidth="271.0" />
<JFXButton alignment="CENTER" prefHeight="36.0" prefWidth="271.0" />
<JFXButton alignment="CENTER" prefHeight="36.0" prefWidth="271.0" />
<JFXButton alignment="CENTER" prefHeight="36.0" prefWidth="271.0" />
<JFXButton alignment="CENTER" prefHeight="36.0" prefWidth="271.0" />
</children>
</VBox>
</content>
</TitledPane>
<TitledPane alignment="CENTER_RIGHT" contentDisplay="GRAPHIC_ONLY" text="untitled 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
<graphic>
<JFXButton alignment="CENTER_RIGHT" contentDisplay="RIGHT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" prefHeight="40.0" prefWidth="217.0">
<graphic>
<FontAwesomeIconView glyphName="HOME" size="1.5em" />
</graphic>
<font>
<Font size="14.0" />
</font>
</JFXButton>
</graphic>
</TitledPane>
<TitledPane alignment="CENTER_RIGHT" contentDisplay="GRAPHIC_ONLY" text="untitled 3">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
<graphic>
<JFXButton alignment="CENTER_RIGHT" contentDisplay="RIGHT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" prefHeight="40.0" prefWidth="215.0">
<graphic>
<FontAwesomeIconView glyphName="HOME" size="1.5em" />
</graphic>
<font>
<Font size="14.0" />
</font>
</JFXButton>
</graphic>
</TitledPane>
</panes>
</Accordion>
</children>
</VBox>
我想要这样的输出
我得到的是
在 Scene Builder 中,所有组件都正确显示,但是当我运行带有 netbeans 按钮文本的项目时没有呈现。请帮助我实现所需的输出。
解决方案
推荐阅读
- python - 有没有办法在 Pandas 中显示 24 小时以上的时间数据?
- c# - 如何在 xaml 中调整大小后获取新窗口高度
- java - 如何保存和加载包含另一个类列表的类?
- javascript - 我需要使用链接文本作为 aria 标签将 aria-label 添加到网站上的所有链接
- jquery - 数据表 Dom 定位引导程序
- c++ - 在使用 std::unique_ptr 在退出作用域块时自动释放内存的情况下,为什么不直接使用堆栈呢?
- checkbox - Semantic-ui 预设复选框状态
- mongodb - 猫鼬 在短语中查找确切的单词
- c# - 我如何将多重断言与 MSTEST (Specflow) 结合起来
- php - 带有负双精度值的 PHP MySQL QUERY