[英]Javafx - Get RGB Value from Node's Color Fill
在我的javafx應用程序中,我創建一個圓圈,然后允許用戶在...中着色它
Circle circle = new Circle();
circle.setFill(colorPicker.getValue());
然后我需要稍后獲取圓圈的顏色並將RGB值變為十六進制形式(#FFFFFF)
circle.getFill(); //returns a Paint object
如何填寫RGB十六進制表格?
嘗試這個:
Color c = (Color) circle.getFill();
String hex = String.format( "#%02X%02X%02X",
(int)( c.getRed() * 255 ),
(int)( c.getGreen() * 255 ),
(int)( c.getBlue() * 255 ) );
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.