aspose file tools*
The moose likes Applets and the fly likes In need of help with making 4x4 grid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "In need of help with making 4x4 grid" Watch "In need of help with making 4x4 grid" New topic
Author

In need of help with making 4x4 grid

kenny gill
Ranch Hand

Joined: Mar 12, 2012
Posts: 54

This is a 2 part project that involves me first making a rectangle and then using it to make a 4x4 grid to display different types of color. The problem is that I have never made or been shown how to make a grid.

here is the project to help clarify:

"Box.java should have these instance variables (all of type int): upperLeftX, upperLeftY, height, width, and one more instance variable of type Color named boxColor. Make them all private and provide Getters and Setters for each instance variable. Tip: Eclipse will build getters and setters for you. Go to the Menu bar in Eclipse and select Source -> Generate Getters and Setters.

Provide the body of the following Constructor that sets the values of the instance variables:

public Box(int upperX, int upperY, int h, int w, Color myColor)

Create a method called display(Graphics g) that uses setColor(boxColor); and fillRect(upperLeftX,upplerLeftY,width, height); to fill our box.

PART II
Also in the java1_BoxProject, Make a Java applet named Grid.java. This applet should display a 4 x 4 grid of boxes, each with a different color (there are 13 standard colors you can look up in the Color Class in the API, you can use a few twice to get 16 boxes).

You must create 16 instances of the Box class and display them. Do not reuse just one box object".

here is my code so far:




Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
And what is the question?
kenny gill
Ranch Hand

Joined: Mar 12, 2012
Posts: 54

To show an example of a 4x4 grid
B Alin
Greenhorn

Joined: Jan 17, 2012
Posts: 8
here you go :


and



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: In need of help with making 4x4 grid