java,web study/2주차 (7월 8일~14일)
그래픽테스트 (awt & swing)
doublemetal
2013. 7. 11. 21:39
윈도우 띄우고 그림 그리기
import java.awt.Graphics;
import javax.swing.JFrame;
public class GraphicTest extends JFrame{
public GraphicTest(String str){
super(str);
setSize(500,500); //창 크기
setLocation(300,300); //창 위치
setVisible(true); //창 보이기
}
public void paint(Graphics g){
g.drawLine(10, 10, 190, 190); //직선
g.drawRect(10,10,100,100); //사각형
g.drawOval(50,50,100,100); //원
g.drawArc(100, 100, 80, 80, 0, 90); //호
}
public static void main(String[] args) {
// TODO Auto-generated method stub
GraphicTest window = new GraphicTest("test"); //타이틀
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //닫기 버튼 활성화
}
}