티스토리 뷰
import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; class MyPanel5 extends JPanel{ @Override public void paintComponent(Graphics g){ g.drawOval(150, 100, 300, 300); g.drawLine(300, 400, 300, 600); g.drawLine(300, 400, 200, 550); g.drawLine(300, 400, 400, 550); g.drawLine(200, 230, 250, 230); g.drawLine(350, 230, 400, 230); g.drawLine(250, 330, 350, 330); } } class MyFrame5 extends JFrame{ public MyFrame5(){ MyPanel5 p = new MyPanel5(); setBackground(Color.WHITE); add(p); setSize(600,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } public class 그래픽예제1 { public static void main(String[] args) { new MyFrame5(); } }
import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; class MyPanel6 extends JPanel{ @Override public void paintComponent(Graphics g){ g.setColor(Color.ORANGE); g.fillOval(150, 100, 300, 300); g.setColor(Color.DARK_GRAY); g.fillOval(200, 200, 50, 50); g.fillOval(350, 200, 50, 50); g.fillArc(250, 250, 100, 100, 0, -180); } } class MyFrame6 extends JFrame{ public MyFrame6(){ MyPanel6 p = new MyPanel6(); setBackground(Color.WHITE); add(p); setSize(600,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } public class 그래픽예제2 { public static void main(String[] args) { new MyFrame6(); } }
'JAVA > PRIMER' 카테고리의 다른 글
자바 입출력 > 이스케이프 문자(escape character) (0) | 2018.11.08 |
---|---|
[JAVA] Color 클래스 (0) | 2018.04.19 |
[JAVA] GUI - 마우스 이벤트 (0) | 2018.04.19 |
[JAVA] GUI - 키 이벤트 (0) | 2018.04.19 |
[JAVA] GUI - JTextField, JTextArea (0) | 2018.04.19 |
댓글