如何在选择框中更改字体颜色?

时间:2018-07-17 06:40:40

标签: javafx fonts colors combobox

我试图在选择框中更改字体颜色,但是发现的所有问题都是更改了里面的标签。我不知道该如何更改字体颜色...

这是我的带有选择框的fxml↓

<ChoiceBox fx:id="capacity_box1" layoutX="43.0" layoutY="113.0" prefHeight="39.0" prefWidth="193.0" styleClass="choiceBox">
     <items>
           <FXCollections fx:factory="observableArrayList">
                  	<fx:reference source="list.millilitre" />
                   	<fx:reference source="list.cubiccentermeter" />
                 	<fx:reference source="list.litre" />
                 	<fx:reference source="list.cubicmeter" />
                 	<fx:reference source="list.Teaspoon" />
                 	<fx:reference source="list.Tablespoon" />
                 	<fx:reference source="list.gallon" />
                 	<fx:reference source="list.cubicinch" />
                 	<fx:reference source="list.cubicfoot" />
             </FXCollections>
       </items>
</ChoiceBox>

1 个答案:

答案 0 :(得分:0)

嗨,我相信我提供了更好的解决方案

在您的 CSS 文件中创建以下内容


final class Transaction: Codable {
    
    var id: Int?
    var date: Date
    var amount: Int
    var planeID: Plane.ID
    var userID: User.ID
    var month: Int
    var year: Int
    //fixes Swift 5 bug
    typealias Database = PostgreSQLDatabase

    
    init(date: Date, amount: Int, planeID: Plane.ID, userID: User.ID, month: Int = 0, year: Int = 0) {
        self.date = date
        self.amount = amount
        self.planeID = planeID
        self.userID = userID
        self.month = month
        self.year = year
    }
}