Bookmark Topic Watch Topic
  • New Topic

How to draw circles whose center coordinates are stored in an array?

 
Rose Jac
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi, can anyone post an example on how to draw n number of circles on a JPanel present within a JFrame, whose center coordinates are stored in an x[] and y[] arrays, where x[] holds the x coordinates and y[] holds y coordinates of the circles, using paintComponent().
I want something like:
A class, say classA, which will have a method, say init() that will add the Jpanel to the Jframe, after instantiating another class, say classB. classB will extend the JPanel. classB will have a method that will generate the values of x and y coordinates and store them in x[] and y[] respectively as well as a paintComponent() which will use these arrays to draw the circles onto a JPanel.
I tried declaring x[] and y[] as class variables but the arrays are still not accessible within the paintComponent().
Please help!
I have been on this since three days!
i have already put 2posts on this but no replies. :|

Thanks!
 
randy orton
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rose Jac wrote:hi, can anyone post an example on how to draw n number of circles on a JPanel present within a JFrame, whose center coordinates are stored in an x[] and y[] arrays, where x[] holds the x coordinates and y[] holds y coordinates of the circles, using paintComponent().
I want something like:
A class, say classA, which will have a method, say init() that will add the Jpanel to the Jframe, after instantiating another class, say classB. classB will extend the JPanel. classB will have a method that will generate the values of x and y coordinates and store them in x[] and y[] respectively as well as a paintComponent() which will use these arrays to draw the circles onto a JPanel.
I tried declaring x[] and y[] as class variables but the arrays are still not accessible within the paintComponent().
Please help!
I have been on this since three days!
i have already put 2posts on this but no replies. :|

Thanks!

I will try to help you if you provide me some code of yours......
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rose, please Use One Thread Per Question.

I'm locking this thread, please continue in the other one.
 
    Bookmark Topic Watch Topic
  • New Topic