• Post Reply Bookmark Topic Watch Topic
  • New Topic

Casting /2D Graphics  RSS feed

 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
can anyone please briefly summarize (maybe with an example) the principle of "Casting" as it relates to 2D Graphics.
[ December 06, 2005: Message edited by: Wolfgang Obi ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not 100% sure what you mean, but probably this: If you override the paint method of java.awt.Component and its subclasses, you get a Graphics object to do the drawing. If you want to use Java2D, you can cast that object to a Graphics2D, like this:
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...And I think since Java 1.2, you can always safely do that cast from
Graphics to Graphics2D -- any object passed to your code by the Swing
framework of type Graphics also has type Graphics2D.
 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the explanation. helped alot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!