This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Creating a filled in Shape using Line2D class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a filled in Shape using Line2D class" Watch "Creating a filled in Shape using Line2D class" New topic
Author

Creating a filled in Shape using Line2D class

Lisa Bergeron
Greenhorn

Joined: Nov 27, 2003
Posts: 7
I know how to create a JFrame and a JPanel then a geometric shape, however, the next problem has me stumped. I read the API specs on the Line2D class which has only confused me further. Can anyone direct me on how to approach the following problem?:
Use a loop to create a filled area. The loop variables will be used by a Line2D Class.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

i'm not sure what you're trying to do exactly, but might you want to have a loop that draws a bunch of lines right next to each other to make a filled shape?
i.e. draw one line from (1,1) to (1,10),
then a line from (2,1) to (2,10)
then (3,1) to (3,10)
...
(10,1) to (10,10)
i think would give you a filled square from (1,1) to (10,10)


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Creating a filled in Shape using Line2D class
 
Similar Threads
adding interfaces to a superclass/subclass relationship
JTextFields & storing data
There is a Line Object?
Please help - Need advice
Applet that lets you draw shapes, custom component and action