FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/Color/TestColor.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
Color
/
TestColor.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
25 lines (20 loc) · 1005 Bytes
Breadcrumbs
java-code-example
/
Color
/
TestColor.java
Copy path
File metadata and controls
executable file
·
25 lines (20 loc) · 1005 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
java
.
awt
.
Color
;
/** âîçìîæíîñòü ñîõðàíåíèÿ öâåòà êàê ñòðîêè òåêñòà è îáðàòíîå ïðåîáðàçîâàíèå */
public
class
TestColor
{
public
static
void
main
(
String
[]
arg
){
Color
colorRed
=
Color
.
red
;
Color
colorDefault
=
new
Color
(
238
,
238
,
238
);
String
stringRed
=
getStringValueFromColor
(
colorRed
);
String
stringDefault
=
getStringValueFromColor
(
colorDefault
);
System
.
out
.
println
(
"StringRed:"
+
stringRed
);
System
.
out
.
println
(
"StringDefault:"
+
stringDefault
);
Color
restoreColorRed
=
Color
.
decode
(
stringRed
);
Color
restoreColorDefault
=
Color
.
decode
(
stringDefault
);
System
.
out
.
println
(
"Restore String Red:"
+
restoreColorRed
.
toString
());
System
.
out
.
println
(
"Restore String Default:"
+
restoreColorDefault
.
toString
());
}
/** ïðåîáðàçîâàòü öâåò â ñòðîêó, êîòîðàÿ ìîæåò áûòü ðàñïîçíàíà ñòàòè÷åñêèì ìåòîäîì Decode*/
private
static
String
getStringValueFromColor
(
Color
color
){
return
"0x"
+
Integer
.
toHexString
((
color
.
getRGB
() &
0xffffff
) |
0x1000000
).
substring
(
1
);
}
}
Back
|
FazBrowse Home
|
New Git URL