ColorPicker中的自定义调色板

编程入门 行业动态 更新时间:2024-10-22 12:22:45
本文介绍了ColorPicker中的自定义调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I would like to change the color palette. The colors are by default have a transparency of 30%.

是否可以替换调色板?

推荐答案

根据此解决方案,您可以在获得矩形及其颜色后替换调色板。

Based on this solution, you can replace the color palette once you get the rectangles and their colors.

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

For instance, you can make brighter all the palette:

@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; }

更多推荐

ColorPicker中的自定义调色板

本文发布于:2023-11-08 20:38:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570395.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:调色板   自定义   ColorPicker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!