aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to draw circles whose center coordinates are stored in an array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

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

Rose Jac
Ranch Hand

Joined: May 20, 2011
Posts: 33
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

Joined: May 20, 2011
Posts: 15
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

Joined: May 03, 2008
Posts: 4530
    
    5

Rose, please Use One Thread Per Question.

I'm locking this thread, please continue in the other one.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to draw circles whose center coordinates are stored in an array?