gpt4 book ai didi

javafx - FXML 文档中 Anchorpane 的代码设置背景颜色

转载 作者:行者123 更新时间:2023-12-02 04:39:37 26 4
gpt4 key购买 nike

我正在 javafx 中创建一个小应用程序。我想设置背景颜色,所以以下是我的 FXML 代码..我需要如何设置背景颜色

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication1.FXMLhomepageController">
<children>
<Label fx:id="lb1" layoutX="139.0" prefHeight="109.0" prefWidth="343.0" text="home page" textAlignment="JUSTIFY" textFill="#355680">
<font>
<Font size="68.0" />
</font>
</Label>
</children>
</AnchorPane>

最佳答案

这是一个例子:

<?import javafx.scene.layout.AnchorPane?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: blue;" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" />

如果您使用Scene Builder,您应该了解如何使用Properties下的此部分:

enter image description here

您还可以使用 CSS 样式表来完成此操作。

关于javafx - FXML 文档中 Anchorpane 的代码设置背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46270959/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com