import java.applet.*; import java.awt.*; // include the above two library files for creating applets public class HelloWorld extends Applet { private Font myFont; private Color myColor; public void init() { // the init method is called when my applet first loads // we'll use it to initialize variable (fields) myFont = new Font("Helvetica", Font.BOLD, 32); setFont(myFont); setBackground(Color.black); setForeground(Color.red); myColor = new Color(80, 124, 224); // red, green, blue (<= 255) } public void paint(Graphics g) { g.drawString("Hello World", 50, 25); g.setColor(myColor); g.drawString("Carman", 100, 150); g.setColor(Color.blue); g.drawRect(5, 8, 49, 29); // draws a rectangle ( x, y, width, height) g.fillRect(25, 25, 100, 100); g.setColor(Color.yellow); g.drawOval(60, 60, 120, 130); // x, y, width, height g.fillOval(80, 80, 110, 110); g.setColor(Color.magenta); g.drawLine(10, 20, 225, 230); g.drawRoundRect(220, 210, 25, 30, 45, 20); // x, y, width, height, arcWidth, arcHeight g.setColor(Color.green); g.drawArc(5, 5, 25, 30, 45, 90); // x, y, width, height, startingAngle, arcAngle g.fillArc(5, 5, 25, 30, 45, 90); } }