Return to lecture notes index
15-100 Lecture 37 (Friday, April 29, 2005)
Exam 3 Retake:

The average score was about a 65%. That is a really good average, considering most people raised their grades by an average of 20%.

Remember that the Mastery Exam will count for 20% of your final grade. That means that you can pull your grade up by around 8% (depending on what your current grade is) due to the Mastery if you get a 100% on it.


All applets have to have certain methods (init, stop, paint) because the class that all applets extend specifies that these methods must exist. (This is because the parent class is what's called an abstract class).

it initalizes the extra variables that you have added to solve the problem. It works like the constructor (although the constructor alreaady exists to make sure the applet is the right size etc.)

this executes when ever the Applet stops running (like when the window is closed)

this is how you can get things to appear on the screen. If you want to change the window that is seen you can just pass in a different graphic. You never call paint. You call repaint...Java will decide if paint needs to be called or not.

You can draw strings to the screen: drawString("Hey hey hey",20,20)...the 20, 20 is marking the place on the screen that the string should start to be drawn. Note that the x,y coordinates on a computer start at the top left and x is positive as it moves right and y is positive as it moves down.

You can change colors (certain colors are already defined: green, red, blue) or create a new color specifying how much red, green, and blue(In order to make colors on a screen using are subtracting from white and use red, green, blue as your prime colors.): new Color(int red, int green, int blue).

You can draw circles: fillArc(int x, int y, int width, int height, int startAngle, int finishAngle)

You can also draw other shapes: check out the full list at the Java API...Java API

You can put images on a screen: a mediaTracker is just one of the ways to do it.

You can have GUI components like buttons, check boxes, text fields, radio buttons (pressing one pops out the rest). If you want a whole bunch of buttons to be managed together (like the radio buttons) you can do this with a CheckboxGroup().

You can have a layout managers:

Border Layout (divides screen into 5 sections: North, south, east, west, and center): setLayout(new BorderLayout())

Grid layout: divides everything into evenly spaced widths and heights.

You can put pannels inside of other pannels. This allows for a more complex looking page.

Getting an applet into a web page:

You just need to add this to the source code for the page:
<applet code="NameOfFile.class" width="300" height="250"></applet>

If you want more information on any of the methods seen in the tutorial go to: Java API