gpt4 book ai didi

java - 更改控件的颜色 FX PopOver 标题

转载 作者:行者123 更新时间:2023-11-28 15:15:41 25 4
gpt4 key购买 nike

想要更改设置为始终打开的控件 FX PopOver 标题的颜色。我想在 CSS 中执行此操作,我已经更改了背景颜色。我在 .popover 下尝试了几个不同的选项。

这是我最后尝试的 CSS 示例:

public class HelloPopOver extends Application {

@Override
public void start(Stage primaryStage) {


//Build PopOver look and feel
Label lblName = new Label("John Doe");
Label lblStreet = new Label("123 Hello Street");
Label lblCityStateZip = new Label("MadeUpCity, XX 55555");
VBox vBox = new VBox(lblName, lblStreet, lblCityStateZip);
//Create PopOver and add look and feel
PopOver popOver = new PopOver(vBox);

// I always want to see my header
popOver.setHeaderAlwaysVisible(true);

Label label = new Label("Mouse mouse over me");
label.setOnMouseEntered(mouseEvent -> {
popOver.show(label);
((Parent)popOver.getSkin().getNode()).getStylesheets().add(getClass().getResource("Style.css").toExternalForm());
});


StackPane root = new StackPane();
root.getChildren().add(label);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}


/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}

还有 CSS:

.popover > .border {
-fx-stroke-width: 0.5;
-fx-fill: rgba(200,200,200, 1);
-fx-text-fill: red; /* This doesn't work, but is what I am looking for */
}
.popover > .label {
-fx-text-fill: red; /* This doesn't work, but is what I am looking for */
}

CSS 如何将标题颜色更改为红色?

最佳答案

我遇到了同样的问题,并通过查看 org.controlsfx.control 中的 popover.css 文件解决了这个问题。

这应该可以解决问题:

.popover > .content > .title > .text  {
-fx-text-fill: red;
}

关于java - 更改控件的颜色 FX PopOver 标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47273123/

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