package com.awtStudy;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Font;
public class GUIstudy extends Frame{
int x=300;
int y=200;
public static void main(String[] args) {
new GUIstudy();
}
public GUIstudy(){
this.setSize(x, y);
setVisible(true);
addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent arg0) {
super.windowClosing(arg0);
dispose();
System.exit(0);
}
});
}
@Override
public void paint(Graphics g) {
super.paint(g);
//글꼴 변경하기 //Font.BOLD+Font.ITALIC=다른 폰트가 된다.
Font f1=new Font("바탕체",Font.BOLD+Font.ITALIC,20);
g.setFont(f1);
g.drawString("안녕 drawString", 10, 100);
g.drawString("1", 10, 40);
g.drawString("2", x-20, 40);
//컬러 ,RGB-red,green,blue
Color c1=new Color(255,1,1);//RED
g.setColor(c1);
g.drawString("3", 10, y-20);
Color c2=new Color(10,30,200);//BLUE
g.setColor(c2);
g.drawString("4", x-20, y-20);
//도형 그리기 x시작점,y시작점 ,넓이 ,높이
g.drawOval( 100, 150 ,30 , 30);
g.fillOval( 200, 150 ,30 , 40);
g.drawRect( 50, 50 ,30 , 30);
g.drawLine(0, 0, x, y);
g.drawLine(x, 0, 0, y);
int x[] =new int[]{100,100,120};
int y[] =new int[]{50,70,70};
g.fillPolygon(x,y,x.length);
g.drawPolygon(x,y,x.length);
}
}