/* Aufgabe1.java */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** * @author Karlheinz Wurm */ public class Aufgabe1 extends Applet { public void paint(Graphics g) { Font tiRomPlain = new Font("TimesRoman",Font.PLAIN,18); Font tiRomBold = new Font("TimesRoman",Font.BOLD,18); Font tiRomItalic = new Font("TimesRoman",Font.ITALIC,18); Font tiRomItBold = new Font("TimesRoman",Font.ITALIC | Font.BOLD,18); Font arialPlain = new Font("Arial",Font.PLAIN,10); Font courierBold = new Font("Courier",Font.BOLD,12); Font arialItalic = new Font("Arial",Font.ITALIC,30); g.setFont(tiRomPlain); g.drawString("Normaler (Plain) Font (TimesRoman) in Schriftgroesse 18",20,50); g.setFont(tiRomBold); g.drawString("Fetter Font (TimesRoman) in Schriftgroesse 18",20,70); g.setFont(tiRomItalic); g.drawString("Kursiv (italic) Font (TimesRoman) in Schriftgroesse 18",20,90); g.setFont(tiRomItBold); g.drawString("Fetter und kursiver Font (TimesRoman) in Schriftgroesse 18",20,110); g.setFont(arialPlain); g.drawString("Normaler Font (Arial) in Schriftgroesse 10",20,122); g.setFont(courierBold); g.drawString("Fetter Font (Courier) in Schriftgroesse 12",20,136); g.setFont(arialItalic); g.drawString("Krusiver Font (Arial) in Schriftgroesse 30",20,168 ); } } /* Aufgabe2.java */ import java.applet.*; import java.awt.*; /** * @author Karlheinz Wurm */ public class Aufgabe2 extends Applet { int width, height; public void init() { Dimension d = getSize(); width = d.width; height = d.height; } public void paint(Graphics g) { Font myFont = new Font("TimesRoman",Font.BOLD,24); FontMetrics myFontMetrics = getFontMetrics(myFont); String myString = "Aller Anfang ist schwer!"; g.setColor(Color.red); g.fillOval( (int)width*0.05, (int)(height*0.05), (int)(width*0.9), (int)(height*0.9)); } } /* Aufgabe3.java */ import java.applet.*; import java.awt.*; /** * @author Karlheinz Wurm */ public class Aufgabe3 extends Applet { public void init() { setBackground(Color.yellow); } public void paint(Graphics g) { int xar[] = {50,120,120,80,80,100,100,80,80,50,50}; int yar[] = {40,40,70,70,100,100,130,130,170,170,40}; g.setColor(Color.red); g.fillPolygon(xar,yar,11); } } /* Aufgabe4.java */ import java.applet.*; import java.awt.*; import java.awt.event.*; /** * @author Karlheinz Wurm */ public class Aufgabe4 extends Applet { int width, height; public void init() { Dimension d = getSize(); width = d.width; height = d.height; } public void paint(Graphics g) { // Ramen wird um 1 Pixel zu gross gezeichnet. g.drawRect(0,0,width,height); // Erst bei -1 wird der genaue Ramen des Fenstern gezeichnet! g.drawRect(0,0,width - 1, height - 1); } }