• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Graphics Program - Making House

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try anything so far?
Try with drawing some basic shapes on panel (triangle, square, ...) and then worry about putting it all together.
 
Muzamil Farooqui
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone else help me out please.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic