// EarthAndMoonApplet.java (c) Kari Laitinen // http://www.naturalprogramming.com/ // 2000-??-?? File created. // 2006-10-18 Latest modification. import java.awt.* ; import javax.swing.* ; public class EarthAndMoonApplet extends JApplet { Font large_font = new Font("TimesRoman", Font.BOLD, 24 ) ; Font italic_font = new Font("TimesRoman", Font.ITALIC, 16 ) ; Font bold_italic = new Font("TimesRoman", Font.BOLD + Font.ITALIC, 14 ) ; public void paint( Graphics graphics ) { super.paint( graphics ) ; graphics.setColor( Color.green ) ; graphics.fillOval( 30, 30, 212, 212 ) ; // Earth graphics.setColor( Color.blue ) ; graphics.fillOval( 400, 100, 58, 58 ) ; // Moon graphics.setColor( Color.black ) ; graphics.setFont( large_font ) ; graphics.drawString( "Earth", 100, 280 ) ; graphics.drawString( "Moon", 400, 200 ) ; graphics.setFont( italic_font ) ; graphics.drawString( "Equatorial radius: 6380 km, 3960 miles", 30, 300 ) ; graphics.drawString( "Radius: 1740 km, 1080 miles", 350, 220 ) ; graphics.setFont( bold_italic ) ; graphics.drawString( "Mean distance between Earth and Moon is", 200, 330 ) ; graphics.drawString( "384 400 kilometers, 238 860 miles", 200, 345 ) ; } }