my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Graphics Program - Making House Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Graphics Program - Making House" Watch "Graphics Program - Making House" New topic
Author

Graphics Program - Making House

Muzamil Farooqui
Greenhorn

Joined: Oct 21, 2012
Posts: 3
Write a graphics program that generates the picture of a house, i need help getting started. Can someone guide the basics like putting the shapes in center and adjusting them. Please
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Did you try anything so far?
Try with drawing some basic shapes on panel (triangle, square, ...) and then worry about putting it all together.


The quieter you are, the more you are able to hear.
Muzamil Farooqui
Greenhorn

Joined: Oct 21, 2012
Posts: 3
Kemal Sokolovic wrote:Did you try anything so far?
Try with drawing some basic shapes on panel (triangle, square, ...) and then worry about putting it all together.


yeh i tried this,

GRect rect = new GRect(100, 50, 125, 60);
rect.setFilled(true);
rect.setColor(Color.RED);
add(rect);

}
}


now i need to know how i can move the shapes around, make them in center, make them fill the whole screen .
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Well, what you are using is not standard Java library class so I can't provide help with that code.

Anyway, use paper to do calculations you need. Draw one rectangle and another one (smaller) inside it, placed at the center of the first one. It will be easy to deduce the position of the smaller one in terms of the big one. Use that conclusion to place rectangle in your code at proper position.

Edit: In addition I would direct you to read Forum Naming Policy.
Muzamil Farooqui
Greenhorn

Joined: Oct 21, 2012
Posts: 3
Can someone else help me out please.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
in standard java you'd use class variables for your bounds
ie instead of
new GRect(100, 50, 125, 60);
you might have
new GRect(x, y, w, h);

and if you wanted to change the position or size you'd adjust
those variables and call repaint()

I don't know what the GRect class is, so you'll have to read the docs
to see if the above is possible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graphics Program - Making House
 
Similar Threads
WA #1.....word association
Jpeg/Gif Image problem
DrawingHouse program
using a hashset to store objects
Java Love