gpt4 book ai didi

java - ColorPicker 中的自定义调色板

转载 作者:行者123 更新时间:2023-11-29 05:09:09 25 4
gpt4 key购买 nike

我想更改调色板。默认情况下,颜色的透明度为 30%。

enter image description here

是否可以更换调色板?

最佳答案

基于此solution ,您可以在获得矩形及其颜色后更换调色板。

例如,您可以使所有调色板更亮:

    @Override
public void start(Stage primaryStage) {
ColorPicker picker = new ColorPicker();
StackPane root = new StackPane(picker);
Scene scene = new Scene(root, 500, 400);

primaryStage.setScene(scene);
primaryStage.show();
picker.showingProperty().addListener((obs,b,b1)->{
if(b1){
PopupWindow popupWindow = getPopupWindow();
Node popup = popupWindow.getScene().getRoot().getChildrenUnmodifiable().get(0);
popup.lookupAll(".color-rect").stream()
.forEach(rect->{
Color c = (Color)((Rectangle)rect).getFill();
// Replace with your custom color
((Rectangle)rect).setFill(c.brighter());
});
}
});
}

private PopupWindow getPopupWindow() {
@SuppressWarnings("deprecation")
final Iterator<Window> windows = Window.impl_getWindows();
while (windows.hasNext()) {
final Window window = windows.next();
if (window instanceof PopupWindow) {
return (PopupWindow)window;
}
}
return null;
}

color picker

关于java - ColorPicker 中的自定义调色板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29299707/

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