package com.graphic2;//Graphics COLOR
import java.awt.*;
import java.awt.event.*;
import java.awt.Frame;
import java.awt.Color;
class GraphicFrame extends Frame{
Color redColor;
//Paint 메서드 오버라이딩
//paint 메소드를 재정의하면 프로그램 구동시 자동으로 호출됨
public void paint(Graphics g){
redColor = new Color(255,0,0);//빨간색
g.setColor(redColor);
g.drawString("빨간색 글자", 10, 50);
g.setColor(Color.GREEN);
g.drawString("초록색 글자", 10, 80);
g.setColor(Color.YELLOW);
g.drawString("노란색 글자", 10, 110);
} //문자열 x,y
public GraphicFrame(){
addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}});
}
}
public class GraphicTest01 {
public static void main(String[] args) {
GraphicFrame f = new GraphicFrame();
f.setSize(270,150);
f.setVisible(true);
}
}