import java.awt.*; import java.awt.geom.*; // needed for the Rectangle2D class import java.applet.Applet; public class FirstApplet extends Applet { public void paint(Graphics g) { // We really want to use a Graphics2D object Graphics2D g2 = (Graphics2D)g; // A couple of methods associated with Graphics and // and Graphics2D. Check the API for both classes // for more methods (and more Fun!) // Writing "Hello" in blue int x = 100, y = 200; g2.setColor(Color.BLUE); g2.drawString("Hello", x, y); // Drawing a red rectangle g2.setColor(Color.RED); g2.fill(new Rectangle2D.Double(50, 50, 50, 50)); // Drawing a black lines between two points g2.setColor(Color.BLACK); int startPointX = 10, startPointY = 20; int endPointX = 100, endPointY = 200; g2.drawLine(startPointX, startPointY, endPointX, endPointY); } }