Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Graphics2D Quandry

  Asked By: Bogart    Date: Dec 18    Category: Java    Views: 381
  

I am a retired mainframe programmer with
lots of experience in IBM Assembler, COBOL, SQL and REXX, but I never did
any PC programming until after retirement when I set out to teach myself
Java... with some pretty good results so far. However, this Graphics2D
has me in a quandry and I'm wondering if anyone can help me:

I'm developing an app to do music notation and I have been contemplating
having a different class to draw each one of the various characters possible
on a music staff (of course, I have to draw the staff, too). I was thinking
of how to accomplish this and had two ideas (neither of which I'm sure of):

1) have each class inherit from JPanel and override the paint(Graphics comp)
method.

2) have one class inherit from Jpanel and all the other classes inherit
from this class, all overriding the paint() method.

The problem, as i see it, is that the paint method is not called explicitly,
and it seems that each time it is called it is passed a Graphics object which
must be cast to a Graphics2D object for drawing. I'm not sure how to get
each class to be able to draw on the same object without having to recreate
everything that has already been drawn. Is there some way, using idea #2
above, in which to cast the Graphics2D object and have all the other classes
then draw on this same object?

Any insight would be appreciated... or maybe a different approach would be
better.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Graphics2D Quandry Or get search suggestion and latest updates.

Related Topics:



Tagged:    

 
 
 
 

Related Post