wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 4523
    
    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.
 
Don't get me started about those stupid light bulbs.
 
subject: How to draw circles whose center coordinates are stored in an array?
 
Similar Threads
Graphics Graphics Graphics - Where are my circles?
Event Handlers:Mouse over "circles"
Drawing circles using the coordinate values that are stored in an ArrayList.
Graphics Graphics Graphics - Where are my circles?
Please help!!!!