¾ÖÇÁ¸´¿¡¼­ÀÇ ±×·¡ÇÈ

/* <html> <head><title>±×·¡ÇÈ °´Ã¼¿¹Á¦ - ¼±±×¸®±â</title></head> <body> <applet code="GraphicsLine" width=350 height=300> </applet> </body> </html> */ import java.awt.*; import java.applet.*; public class GraphicsLine extends Applet { public void paint(Graphics g) { g.drawLine(10, 10, 100, 10); g.drawLine(100, 10, 100, 100); g.drawLine(100, 100, 10, 100); g.drawLine(10, 100, 10, 10); g.drawLine(10, 10, 100, 100); g.drawLine(10, 100, 100, 10); } } /* <html> <head><title>±×·¡ÇÈ °´Ã¼¿¹Á¦ - »ç°¢Çü±×¸®±â</title></head> <body> <applet code="GraphicsRectangles" width=350 height=300> </applet> </body> </html> */ import java.awt.*; import java.applet.*; public class GraphicsRectangles extends Applet { public void paint(Graphics g) { g.drawRect(10, 10, 100, 100); g.fillRect(120, 10, 100, 100); g.fillRoundRect(10, 120, 100, 100, 15, 15); g.drawRoundRect(120, 120, 100, 100, 30, 40); } } /* <html> <head><title>±×·¡ÇÈ °´Ã¼¿¹Á¦ - ¿ø & È£ </title></head> <body> <applet code="GraphicsCircle" width=350 height=300> </applet> </body> </html> */ import java.awt.*; import java.applet.*; public class GraphicsCircle extends Applet { public void paint(Graphics g) { g.drawOval(10, 10, 50, 50); g.fillOval(100, 10, 75, 50); g.drawArc(210, 50, 70, 70, 0, 75); g.fillArc(150, 50, 90, 90, 0, 75); g.drawArc(10, 100, 70, 80, 0, 175); g.fillArc(100, 100, 70, 90, 180, 270); } } /* <html> <head><title>µ¿Àû±×·¡ÇÈ »ç°¢Çü±×¸®±â</title></head> <body> <applet code="DynamicRectangle" width=350 height=300> </applet> </body> </html> */ import java.applet.*; import java.awt.*; public class DynamicRectangle extends Applet { public void paint(Graphics g) { Dimension d = getSize(); int v = d.width/2; int h = d.height/2; int radius = (int)((d.width < d.height) ? 0.4 * d.width : 0.4 * d.height); g.drawRect(v - radius, h - radius, 2 * radius, 2 * radius); } } /* <html> <head><title>Color¿¹Á¦</title></head> <body> <applet code="ColorFont" width=300 height=100> </applet> </body> </html> */ import java.applet.Applet; import java.awt.*; public class ColorFont extends Applet { public void paint(Graphics g) { g.setColor(Color.red); g.drawString("¾Ë±â½±°Ô ÇØ¼³ÇÑ JAVA", 50, 50); g.setColor(Color.blue); g.drawString("°´Ã¼ÁöÇâ ÇÁ·Î±×·¡¹Ö", 50, 80); } } /* <html> <head><title>Color ¿¹Á¦</title></head> <body> <applet code="ColorExam" width=300 height=200> </applet> </body> </html> */ import java.awt.*; import java.applet.*; public class ColorExam extends Applet { // draw lines public void paint(Graphics g) { Color c1 = new Color(255, 100, 100); Color c2 = new Color(100, 255, 100); Color c3 = new Color(100, 100, 255); g.setColor(c1); g.drawLine(0, 0, 100, 100); g.setColor(c2); g.drawLine(40, 25, 250, 180); g.setColor(c3); g.drawLine(20, 150, 400, 40); g.setColor(Color.red); g.drawOval(10, 10, 50, 50); g.fillOval(70, 90, 140, 100); g.setColor(Color.blue); g.drawOval(190, 10, 90, 30); g.drawRect(10, 10, 60, 50); g.setColor(Color.cyan); g.fillRect(100, 10, 60, 50); g.drawRoundRect(190, 10, 60, 50, 15, 15); } } /* <html> <head><title>Font¿¹Á¦</title></head> <body> <applet code="SetFont" width=400 height=150> </applet> </body> </html> */ import java.awt.*; import java.applet.*; public class SetFont extends Applet { Graphics g; Font courier; Font timesroman; Font symbol; Font etc; public void init() { courier = new Font("Courier",Font.BOLD,20); timesroman = new Font("Timesroman",Font.BOLD,20); symbol = new Font("Symbol",Font.BOLD,20); etc = new Font("±¼¸²",Font.BOLD,20); } public void paint(Graphics g) { g.setFont(courier); g.drawString("Teach you self JAVA : Courier ",20,20); g.setFont(timesroman); g.drawString("Complete Reference JAVA : Timesoroman ",20,50); g.setFont(symbol); g.drawString("JAVA Tutorial : Symbol ",20,82); g.setFont(etc); g.drawString("¾Ë±â½±°Ô ÇØ¼³ÇÑ ÀÚ¹Ù : ±¼¸²Ã¼",20,118); } } /* <html> <head><title>Font¿¹Á¦</title></head> <body> <applet code="FontExample" width=400 height=200> </applet> </body> </html> */ import java.applet.Applet; import java.awt.*; public class FontExample extends Applet { public void paint(Graphics g) { int baseline = 70; g.setColor(Color.red); g.drawLine(0, baseline, 350, baseline); // »¡°£»öÀ¸·Î ÆùÆ®ÀÇ ±âÁؼ±(baseline)À» ±ß´Â´Ù Font font = new Font("SansSerif", Font.PLAIN, 30); g.setFont(font); g.setColor(Color.black); g.drawString("Hi java ¾È³çÇϼ¼¿ä?", 5, baseline); // ÆùÆ®¸¦ ¼³Á¤ÇÑ ´ÙÀ½ ±âÁؼ±¿¡ ¹®ÀÚ¿­À» Ãâ·Â FontMetrics font1 = g.getFontMetrics(font); int ascent = font1.getAscent(); // ÆùÆ®ÀÇ ¸Ó¸®¼±(ascent) Å©±â¸¦ ¾ò´Â´Ù int y = baseline - ascent; g.setColor(Color.green); g.drawLine(0, y, 350, y); // ¸Ó¸®¼±À» ±ß´Â´Ù int descent = font1.getDescent(); // ÆùÆ®ÀÇ ²¿¸®¼± Å©±â¸¦ ¾ò´Â´Ù y = baseline + descent; g.setColor(Color.blue); g.drawLine(0, y, 350, y); // ²¿¸®¼±À» ±ß´Â´Ù } }