티스토리 뷰
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(); } }
'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 |
댓글