File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

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:

" 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.

Also in the java1_BoxProject, Make a Java applet named 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

Joined: Oct 13, 2005
Posts: 46424
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

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


I agree. Here's the link:
subject: In need of help with making 4x4 grid
It's not a secret anymore!