I'm new in JavaFx
but have good knowledge in Java. Now basically I'm learning at the moment with this program:
我是JavaFx的新手,但对Java有很好的了解。现在基本上我正在学习这个程序:
package com.lesson;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Button;
import javafx.scene.control.Accordion;
public class MyProgram extends Application{
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage primaryStage){
primaryStage.setTitle("My anme is rajedra");
Group group=new Group();
Scene s=new Scene(group, 400, 400, Color.web("0x0001FF", 1.0));
TitledPane tp1=new TitledPane("T1", new Button("B1"));
TitledPane tp2=new TitledPane("T2", new Button("b2"));
TitledPane tp3=new TitledPane("T3", new Button("b3"));
TitledPane tp4=new TitledPane("T4", new Button("b4"));
Accordion accordion=new Accordion();
accordion.getPanes().addAll(tp1, tp2, tp3);
group.getChildren().add(accordion);
primaryStage.setScene(s);
primaryStage.show();
}
}
But don't understand exactly what Color.web("0x0001FF", 1.0)
here? I found background color shows Blue
After running this program. But I haven't typed any blue
or any Code
which tends to show. Now what's that mean here please help.
但是不明白究竟什么是Color.web(“0x0001FF”,1.0)?我发现背景颜色显示Blue运行此程序后。但我没有输入任何蓝色或任何倾向于显示的代码。现在这意味着什么,请帮忙。
Help would be appreciated! :)
帮助将不胜感激! :)
Thanks
4 个解决方案
#1
1
It's a color defined by the hex 0001FF
, with 100% (1.0) opacity.
它是由六角形0001FF定义的颜色,具有100%(1.0)不透明度。
Why is it blue?
它为什么是蓝色的?
Because a hex colour is written like this:
因为十六进制颜色是这样写的:
00 01 FF
^^ ^^ ^^
RED GREEN BLUE
In decimal, 00
is 0
, FF
is 255
.
在十进制中,00为0,FF为255。
In RGB, every colour value can go from 0
(no colour) to 255
(full colour).
在RGB中,每个颜色值可以从0(无颜色)到255(全彩色)。
So you are filling it with 255 blue (100%), 1 Green (which slightly modifies the blue, there is almost no visual difference) and 0 red.
所以你填充255蓝色(100%),1绿色(略微修改蓝色,几乎没有视觉差异)和0红色。
#2
1
Check the relevant javadoc.
检查相关的javadoc。
First parameter of the Color.web()
method is the RGB (Red, Green, Blue) value of the color.
Color.web()方法的第一个参数是颜色的RGB(红色,绿色,蓝色)值。
"0x0001FF"
This has 0x00
red component, 0x01
green component (almost zero) and full 0xff
blue component.
这有0x00红色组件,0x01绿色组件(几乎为零)和完整0xff蓝色组件。
The second parameter of the Color.web()
is the opacity in the range from 0.0
(transparent) to 1.0
(opaque, this is your case).
Color.web()的第二个参数是不透明度,范围从0.0(透明)到1.0(不透明,这是你的情况)。
Therefore your result color is blue.
因此,您的结果颜色为蓝色。
#3
1
0x0001ff
is a hex-representation of a color in RGB
: 1 byte per color component. So it's
0x0001ff是RGB中颜色的十六进制表示:每个颜色分量1个字节。所以这是
0x00
(0/255) for Red
红色为0x00(0/255)
0x01
(1/255) for Green
绿色为0x01(1/255)
0xff
(255/255) for Blue.
蓝色为0xff(255/255)。
That's why it's blue.
这就是为什么它是蓝色的原因。
1.0
stays for opacity. 0.0
is completely transparent, 1.0
is opaque. You can specify any value in between.
1.0保持不透明度。 0.0是完全透明的,1.0是不透明的。您可以指定其间的任何值。
#4
0
0001FF is the hex code for blue: http://www.colorhexa.com/0001ff
0001FF是蓝色的十六进制代码:http://www.colorhexa.com/0001ff
Thus, you background appears to be blue.
因此,您的背景看起来是蓝色的。
#1
1
It's a color defined by the hex 0001FF
, with 100% (1.0) opacity.
它是由六角形0001FF定义的颜色,具有100%(1.0)不透明度。
Why is it blue?
它为什么是蓝色的?
Because a hex colour is written like this:
因为十六进制颜色是这样写的:
00 01 FF
^^ ^^ ^^
RED GREEN BLUE
In decimal, 00
is 0
, FF
is 255
.
在十进制中,00为0,FF为255。
In RGB, every colour value can go from 0
(no colour) to 255
(full colour).
在RGB中,每个颜色值可以从0(无颜色)到255(全彩色)。
So you are filling it with 255 blue (100%), 1 Green (which slightly modifies the blue, there is almost no visual difference) and 0 red.
所以你填充255蓝色(100%),1绿色(略微修改蓝色,几乎没有视觉差异)和0红色。
#2
1
Check the relevant javadoc.
检查相关的javadoc。
First parameter of the Color.web()
method is the RGB (Red, Green, Blue) value of the color.
Color.web()方法的第一个参数是颜色的RGB(红色,绿色,蓝色)值。
"0x0001FF"
This has 0x00
red component, 0x01
green component (almost zero) and full 0xff
blue component.
这有0x00红色组件,0x01绿色组件(几乎为零)和完整0xff蓝色组件。
The second parameter of the Color.web()
is the opacity in the range from 0.0
(transparent) to 1.0
(opaque, this is your case).
Color.web()的第二个参数是不透明度,范围从0.0(透明)到1.0(不透明,这是你的情况)。
Therefore your result color is blue.
因此,您的结果颜色为蓝色。
#3
1
0x0001ff
is a hex-representation of a color in RGB
: 1 byte per color component. So it's
0x0001ff是RGB中颜色的十六进制表示:每个颜色分量1个字节。所以这是
0x00
(0/255) for Red
红色为0x00(0/255)
0x01
(1/255) for Green
绿色为0x01(1/255)
0xff
(255/255) for Blue.
蓝色为0xff(255/255)。
That's why it's blue.
这就是为什么它是蓝色的原因。
1.0
stays for opacity. 0.0
is completely transparent, 1.0
is opaque. You can specify any value in between.
1.0保持不透明度。 0.0是完全透明的,1.0是不透明的。您可以指定其间的任何值。
#4
0
0001FF is the hex code for blue: http://www.colorhexa.com/0001ff
0001FF是蓝色的十六进制代码:http://www.colorhexa.com/0001ff
Thus, you background appears to be blue.
因此,您的背景看起来是蓝色的。