• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Draw a cylinder

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the easiest way to draw a cylinder within a JPanel? Is there a method similar to drawOval for the Graphics object? Any help would be appreciated. Thanks.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break down the cylinder into its component parts. You already know about drawOval so that's half of the job. I expect you also know about the method required to draw a straight line. Besides that there's just some arithmetic required to figure out where to draw each of the parts.
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
So no shortcut? :-) I didn't want to go ahead and re-invent the wheel if something already existed. Thanks for the feedback.
RH
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't checked. You could look at the Graphics documentation for yourself to see if there's drawCylinder or whatever. I just know from experience that people who write APIs don't typically write a ton of convenience methods like that, especially when they just involve simple extensions which anybody could do in a few minutes. You might find that somebody else has written a fancy graphics package which has that ton of convenience methods, though.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there are no methods to draw 2D representations of 3D objects in the core API. There's Java3D, but that's a whole different animal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic