티스토리 뷰

JAVA/PRIMER

[JAVA] Color 클래스

yulrang 2018. 4. 19. 14:21
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import·java.awt.Color;¬
import·java.awt.Graphics;¬
¬
import·javax.swing.JFrame;¬
import·javax.swing.JPanel;¬
¬
class·MyPanel7·extends·JPanel{¬
————Color·c1·=·new·Color(240,140,140);——//·RGB·int·¬
————Color·c2·=·new·Color(0.5f,0.7f,1f);¬
————Color·c3·=·new·Color(0x00CCCCCC);———//··¬
————¬
————public·void·paintComponent(Graphics·g){¬
————————g.setColor(c2);¬
————————g.fillArc(10,10,50,50,0,180);¬
————————g.fillArc(59,10,50,50,0,180);¬
————————¬
————————int[]·x1·=·{10,110,50};¬
————————int[]·y1·=·{35,35,130};¬
————————g.fillPolygon(x1,y1,3);¬
————}¬
}¬
¬
class·MyFrame7·extends·JFrame{¬
————public·MyFrame7(){¬
————————MyPanel7·p·=·new·MyPanel7();¬
————————add(p);¬
————————¬
————————setSize(600,600);¬
————————setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);¬
————————setVisible(true);¬
————}¬
}¬
public·class·1·{¬
¬
————public·static·void·main(String[]·args)·{¬
————————new·MyFrame7();¬
¬
————}¬
¬
}¬
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


'JAVA > PRIMER' 카테고리의 다른 글

자바 입출력 > 이스케이프 문자(escape character)  (0) 2018.11.08
[JAVA] JPanel - paintComponent  (0) 2018.04.19
[JAVA] GUI - 마우스 이벤트  (0) 2018.04.19
[JAVA] GUI - 키 이벤트  (0) 2018.04.19
[JAVA] GUI - JTextField, JTextArea  (0) 2018.04.19
댓글