【发布时间】:2019-04-04 09:21:26
【问题描述】:
我对 Scene Builder 和 JavaFXML 还很陌生。当我向锚窗格添加标签时,我无法更改文本的字体及其颜色。这两个选项都是灰色的,旁边有这个 CSS 标题。 我怎样才能不禁用这些选项?按钮也是如此。
FXML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="672.0" prefWidth="176.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane prefHeight="188.0" prefWidth="176.0" style="-fx-background-color: #1c94d900;">
<children>
<Label fx:id="StudentUSN" layoutX="15.0" layoutY="145.0" prefHeight="24.0" prefWidth="146.0" />
</children>
</AnchorPane>
<VBox prefHeight="464.0" prefWidth="176.0">
<children>
<JFXButton fx:id="b1" prefHeight="44.0" prefWidth="176.0" style="-fx-background-color: #1156cf;" text="Attendance" />
<JFXButton fx:id="b2" disable="true" prefHeight="44.0" prefWidth="176.0" style="-fx-background-color: #1156cf;" text="Clubs" />
<JFXButton fx:id="b3" disable="true" prefHeight="48.0" prefWidth="176.0" style="-fx-background-color: #1156cf;" text="Results" />
<JFXButton fx:id="b4" disable="true" prefHeight="48.0" prefWidth="176.0" style="-fx-background-color: #1156cf;" text="Feedback" />
</children>
</VBox>
</children>
</VBox>
【问题讨论】:
-
您是否在标签上设置了自定义样式?请发布完整的 FXML。
-
不,我不记得设置任何自定义样式。 @sillyfly
-
你确定这是同一个文件吗?一方面 - 您发布的 FXML 中的标签没有文本。此外 - 如果您不包含
jfoenix库,是否会发生这种情况? -
是的,这是同一个文件。后来我改了文字。是的,即使我没有包含 jfoenix 库,它也会发生。
-
您能否检查 FXML 是否应用了样式表?转到 Scene Builder 预览菜单,选择
Scene Style Sheets,然后查看在Remove a Style Sheet下是否找到列出的任何 CSS。如果是这样,删除它应该可以让您完全控制您的 FXML 样式。
标签: css javafx scenebuilder