Programming in Java

Lab 6

In this lab you will create some applets.

  1. Create an applet that contains some text, some drawing, including a box drawn around the text, and an image which is centered horizontally in the applet. Feel free to be creative! There are lots of places to get images on the net; one place that has many images is www.iconbazaar.com.

  2. Create an applet that draws a 10 by 10 grid of squares, like a chessboard. Place an image in the center of the applet. For now you'll have to estimate, so it doesn't have to be in the exact center. Use trial and error to get it close. Use the size of the applet to determine the size of each square. Use two colors for your grid.

  3. Create another version of the grid applet. In this version, use random colors for the squares of the grid. To create colors, use the static method getHSBColor, which is in the java.awt.Color class:
    
    	public static Color getHSBColor(float h,float s,float b);
    
    
    which creates a color using three numbers. Each number is a float between 0.0 and 1.0. Use the random number generator class, java.util.Random to get a random number for each of the parameters to getHSBColor.

I put copies of the applets for 2. and 3. on my web page if you want to see what they should look like. You can find them from the labs page.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page